Skip to content

Commit d9dc130

Browse files
fhinkelGabriel Schulhof
authored and
Gabriel Schulhof
committed
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: nodejs#17424 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 45a3e6b commit d9dc130

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)