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

Function CreateFunctionReferenceUsingNew

test/function_reference.cc:140–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140Value CreateFunctionReferenceUsingNew(const Napi::CallbackInfo& info) {
141 Napi::Function func = ObjectWrap<FuncRefObject>::DefineClass(
142 info.Env(),
143 "MyObject",
144 {ObjectWrap<FuncRefObject>::InstanceMethod("getValue",
145 &FuncRefObject::GetValue)});
146 Napi::FunctionReference* constructor = new Napi::FunctionReference();
147 *constructor = Napi::Persistent(func);
148
149 return MaybeUnwrapOr(constructor->New({info[0].As<Number>()}), Object());
150}
151
152Value CreateFunctionReferenceUsingNewVec(const Napi::CallbackInfo& info) {
153 Napi::Function func = ObjectWrap<FuncRefObject>::DefineClass(

Callers

nothing calls this directly

Calls 5

PersistentFunction · 0.85
MaybeUnwrapOrFunction · 0.85
ObjectClass · 0.85
EnvMethod · 0.80
NewMethod · 0.80

Tested by

no test coverage detected