From 2475676995ab04cb821a5bdb4d39cc4ecba70205 Mon Sep 17 00:00:00 2001 From: Franziska Hinkelmann Date: Mon, 4 Dec 2017 18:45:22 +0100 Subject: [PATCH] doc: update example in module registration Update return type of `Init` function in documentation to match `napi_addon_register_func` signature. Return type used to be `void`, now it is `napi_value`. PR-URL: https://github.com/nodejs/node/pull/17424 Reviewed-By: Michael Dawson Reviewed-By: James M Snell --- doc/api/n-api.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index c91927a4ee8304..0843165f075be9 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -2879,15 +2879,17 @@ napi_value SayHello(napi_env env, napi_callback_info info) { return nullptr; } -void Init(napi_env env, napi_value exports, napi_value module, void* priv) { +napi_value Init(napi_env env, napi_value exports) { napi_status status; napi_value fn; - status = napi_create_function(env, NULL, SayHello, NULL, &fn); - if (status != napi_ok) return; + status = napi_create_function(env, nullptr, 0, SayHello, nullptr, &fn); + if (status != napi_ok) return nullptr; status = napi_set_named_property(env, exports, "sayHello", fn); - if (status != napi_ok) return; + if (status != napi_ok) return nullptr; + + return exports; } NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)