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

Function VoidCallback

test/maybe/check.cc:9–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7namespace {
8
9void VoidCallback(const CallbackInfo& info) {
10 Napi::Function fn = info[0].As<Function>();
11 Maybe<Value> ret = fn.Call({});
12
13 assert(ret.IsNothing() == true);
14 assert(ret.IsJust() == false);
15
16 Napi::Value placeHolder = Napi::Number::New(info.Env(), 12345);
17 Napi::Value unwrappedValue = ret.UnwrapOr(placeHolder);
18
19 assert(unwrappedValue.As<Number>().Uint32Value() == 12345);
20
21 assert(ret.UnwrapTo(&placeHolder) == false);
22 assert(placeHolder.As<Number>().Uint32Value() == 12345);
23
24 ret.Check();
25}
26
27void TestMaybeOperatorOverload(const CallbackInfo& info) {
28 Napi::Function fn_a = info[0].As<Function>();

Callers

nothing calls this directly

Calls 7

CallMethod · 0.80
IsNothingMethod · 0.80
IsJustMethod · 0.80
EnvMethod · 0.80
UnwrapOrMethod · 0.80
UnwrapToMethod · 0.80
CheckMethod · 0.80

Tested by

no test coverage detected