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

Function ThenMethodOnFulfilledOnRejectedResolve

test/promise.cc:43–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43Value ThenMethodOnFulfilledOnRejectedResolve(const CallbackInfo& info) {
44 auto deferred = Promise::Deferred::New(info.Env());
45 Function onFulfilled = info[0].As<Function>();
46 Function onRejected = info[1].As<Function>();
47
48 Promise resultPromise =
49 MaybeUnwrap(deferred.Promise().Then(onFulfilled, onRejected));
50
51 bool isPromise = resultPromise.IsPromise();
52 deferred.Resolve(Number::New(info.Env(), 42));
53
54 Object result = Object::New(info.Env());
55 result["isPromise"] = Boolean::New(info.Env(), isPromise);
56 result["promise"] = resultPromise;
57
58 return result;
59}
60
61Value ThenMethodOnFulfilledOnRejectedReject(const CallbackInfo& info) {
62 auto deferred = Promise::Deferred::New(info.Env());

Callers

nothing calls this directly

Calls 5

MaybeUnwrapFunction · 0.85
EnvMethod · 0.80
ThenMethod · 0.80
PromiseMethod · 0.80
ResolveMethod · 0.80

Tested by

no test coverage detected