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

Function ThenMethodOnFulfilledOnRejectedReject

test/promise.cc:61–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61Value ThenMethodOnFulfilledOnRejectedReject(const CallbackInfo& info) {
62 auto deferred = Promise::Deferred::New(info.Env());
63 Function onFulfilled = info[0].As<Function>();
64 Function onRejected = info[1].As<Function>();
65
66 Promise resultPromise =
67 MaybeUnwrap(deferred.Promise().Then(onFulfilled, onRejected));
68
69 bool isPromise = resultPromise.IsPromise();
70 deferred.Reject(String::New(info.Env(), "Rejected"));
71
72 Object result = Object::New(info.Env());
73 result["isPromise"] = Boolean::New(info.Env(), isPromise);
74 result["promise"] = resultPromise;
75
76 return result;
77}
78
79Value CatchMethod(const CallbackInfo& info) {
80 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
RejectMethod · 0.80

Tested by

no test coverage detected