◐ Shell
clean mode source ↗

doc: naming function as suggested in addon docs · nodejs/node@5fa5ab6

Original file line numberDiff line numberDiff line change

@@ -72,11 +72,11 @@ void Method(const FunctionCallbackInfo<Value>& args) {

7272

args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world"));

7373

}

7474
75-

void init(Local<Object> exports) {

75+

void Initialize(Local<Object> exports) {

7676

NODE_SET_METHOD(exports, "hello", Method);

7777

}

7878
79-

NODE_MODULE(NODE_GYP_MODULE_NAME, init)

79+

NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize)

8080
8181

} // namespace demo

8282

```

@@ -95,8 +95,8 @@ There is no semi-colon after `NODE_MODULE` as it's not a function (see

9595

The `module_name` must match the filename of the final binary (excluding

9696

the `.node` suffix).

9797
98-

In the `hello.cc` example, then, the initialization function is `init` and the

99-

Addon module name is `addon`.

98+

In the `hello.cc` example, then, the initialization function is `Initialize`

99+

and the addon module name is `addon`.

100100
101101

### Building

102102