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

Function ThenMethodOnFulfilled

test/promise.cc:27–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27Value ThenMethodOnFulfilled(const CallbackInfo& info) {
28 auto deferred = Promise::Deferred::New(info.Env());
29 Function onFulfilled = info[0].As<Function>();
30
31 Promise resultPromise = MaybeUnwrap(deferred.Promise().Then(onFulfilled));
32
33 bool isPromise = resultPromise.IsPromise();
34 deferred.Resolve(Number::New(info.Env(), 42));
35
36 Object result = Object::New(info.Env());
37 result["isPromise"] = Boolean::New(info.Env(), isPromise);
38 result["promise"] = resultPromise;
39
40 return result;
41}
42
43Value ThenMethodOnFulfilledOnRejectedResolve(const CallbackInfo& info) {
44 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