Skip to content

Commit cd7cee5

Browse files
fhinkelMylesBorins
authored andcommitted
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: #17424 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 07fd4cf commit cd7cee5

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
@@ -2879,15 +2879,17 @@ napi_value SayHello(napi_env env, napi_callback_info info) {
28792879
return nullptr;
28802880
}
28812881

2882-
void Init(napi_env env, napi_value exports, napi_value module, void* priv) {
2882+
napi_value Init(napi_env env, napi_value exports) {
28832883
napi_status status;
28842884

28852885
napi_value fn;
2886-
status = napi_create_function(env, NULL, SayHello, NULL, &fn);
2887-
if (status != napi_ok) return;
2886+
status = napi_create_function(env, nullptr, 0, SayHello, nullptr, &fn);
2887+
if (status != napi_ok) return nullptr;
28882888

28892889
status = napi_set_named_property(env, exports, "sayHello", fn);
2890-
if (status != napi_ok) return;
2890+
if (status != napi_ok) return nullptr;
2891+
2892+
return exports;
28912893
}
28922894

28932895
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)

0 commit comments

Comments
 (0)