Skip to content

Commit 173f297

Browse files
fhinkelMylesBorins
authored andcommittedApr 16, 2018
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`. Backport-PR-URL: #19447 PR-URL: #17424 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d4284a4 commit 173f297

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎doc/api/n-api.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -2877,15 +2877,17 @@ napi_value SayHello(napi_env env, napi_callback_info info) {
28772877
return nullptr;
28782878
}
28792879

2880-
void Init(napi_env env, napi_value exports, napi_value module, void* priv) {
2880+
napi_value Init(napi_env env, napi_value exports) {
28812881
napi_status status;
28822882

28832883
napi_value fn;
2884-
status = napi_create_function(env, NULL, SayHello, NULL, &fn);
2885-
if (status != napi_ok) return;
2884+
status = napi_create_function(env, nullptr, 0, SayHello, nullptr, &fn);
2885+
if (status != napi_ok) return nullptr;
28862886

28872887
status = napi_set_named_property(env, exports, "sayHello", fn);
2888-
if (status != napi_ok) return;
2888+
if (status != napi_ok) return nullptr;
2889+
2890+
return exports;
28892891
}
28902892

28912893
NAPI_MODULE(addon, Init)

0 commit comments

Comments
 (0)
Please sign in to comment.