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 <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Franziska Hinkelmann authored and Myles Borins committed 2017-12-12 03:28:12 -05:00
1 parent 07fd4cfbe0
commit cd7cee57e9
1 file changed
+6 -4
+6 -4
View File
@@ -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)