MCPcopy Create free account
hub / github.com/nodejs/nan / NAN_MODULE_INIT

Method NAN_MODULE_INIT

test/cpp/objectwraphandle.cpp:15–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13class MyObject : public ObjectWrap {
14 public:
15 static NAN_MODULE_INIT(Init) {
16 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
17 tpl->SetClassName(Nan::New("MyObject").ToLocalChecked());
18 tpl->InstanceTemplate()->SetInternalFieldCount(1);
19
20 SetPrototypeMethod(tpl, "getHandle", GetHandle);
21 SetPrototypeMethod(tpl, "getHandleConst", GetHandleConst);
22 SetPrototypeMethod(tpl, "getValue", GetValue);
23
24 constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
25 Set(target, Nan::New("MyObject").ToLocalChecked(),
26 Nan::GetFunction(tpl).ToLocalChecked());
27 }
28
29 private:
30 explicit MyObject(double value = 0) : value_(value) {}

Callers

nothing calls this directly

Calls 6

SetPrototypeMethodFunction · 0.85
ToLocalCheckedMethod · 0.80
NewFunction · 0.50
GetFunctionFunction · 0.50
SetFunction · 0.50
ResetMethod · 0.45

Tested by

no test coverage detected