Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cd7cee5

Browse filesBrowse 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 <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 07fd4cf commit cd7cee5
Copy full SHA for cd7cee5

File tree

Expand file treeCollapse file tree

1 file changed

+6
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-4
lines changed
Open diff view settings
Collapse file

‎doc/api/n-api.md‎

Copy file name to clipboardExpand all lines: doc/api/n-api.md
+6-4Lines changed: 6 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.