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

Function MakeAsyncCallbackWithArgv

test/function_reference.cc:122–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122Value MakeAsyncCallbackWithArgv(const Napi::CallbackInfo& info) {
123 Napi::FunctionReference ref;
124 ref.Reset(info[0].As<Function>());
125
126 size_t argLength = info.Length() > 1 ? info.Length() - 1 : 0;
127 std::unique_ptr<napi_value[]> args{argLength > 0 ? new napi_value[argLength]
128 : nullptr};
129 for (size_t i = 0; i < argLength; ++i) {
130 args[i] = info[i + 1];
131 }
132
133 Napi::AsyncContext context(info.Env(), "func_ref_resources", {});
134 return MaybeUnwrap(ref.MakeCallback(Napi::Object::New(info.Env()),
135 argLength,
136 argLength > 0 ? args.get() : nullptr,
137 context));
138}
139
140Value CreateFunctionReferenceUsingNew(const Napi::CallbackInfo& info) {
141 Napi::Function func = ObjectWrap<FuncRefObject>::DefineClass(

Callers

nothing calls this directly

Calls 5

MaybeUnwrapFunction · 0.85
ResetMethod · 0.80
LengthMethod · 0.80
EnvMethod · 0.80
MakeCallbackMethod · 0.80

Tested by

no test coverage detected