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: https://github.com/nodejs/node/pull/17424 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
f6b2839bc3
commit
2475676995
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user