MCPcopy Index your code
hub / github.com/nodejs/node-addon-api / Init

Method Init

test/addon_data.cc:66–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64 }
65
66 static Napi::Object Init(Napi::Env env, Napi::Value jshint) {
67 if (!jshint.IsNumber()) {
68 NAPI_THROW(Napi::Error::New(env, "Expected number"), Napi::Object());
69 }
70 uint32_t hint = jshint.As<Napi::Number>();
71 if (hint == 0)
72 env.SetInstanceData(new Addon(env));
73 else
74 env.SetInstanceData<Addon, uint32_t, DeleteAddon>(new Addon(env),
75 new uint32_t(hint));
76 Napi::Object result = Napi::Object::New(env);
77 result.DefineProperties({
78 Napi::PropertyDescriptor::Accessor<Getter, Setter>("verbose"),
79 });
80
81 return result;
82 }
83
84 private:
85 bool verbose = false;

Callers

nothing calls this directly

Calls 3

ObjectClass · 0.85
SetInstanceDataMethod · 0.80
DefinePropertiesMethod · 0.80

Tested by

no test coverage detected