Skip to content

Commit

Permalink
doc: update example in module registration
Browse files Browse the repository at this point in the history
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: #17424
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
fhinkel authored and MylesBorins committed Dec 12, 2017
1 parent 07fd4cf commit cd7cee5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cd7cee5

Please sign in to comment.