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`.

Backport-PR-URL: #19447
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 Apr 16, 2018
1 parent d4284a4 commit 173f297
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions doc/api/n-api.md
Expand Up @@ -2877,15 +2877,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(addon, Init)
Expand Down

0 comments on commit 173f297

Please sign in to comment.