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

Method Then

napi-inl.h:2989–3010  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2987inline Promise::Promise(napi_env env, napi_value value) : Object(env, value) {}
2988
2989inline MaybeOrValue<Promise> Promise::Then(napi_value onFulfilled) const {
2990 EscapableHandleScope scope(_env);
2991#ifdef NODE_ADDON_API_ENABLE_MAYBE
2992 Value thenMethod;
2993 if (!Get("then").UnwrapTo(&thenMethod)) {
2994 return Nothing<Promise>();
2995 }
2996 MaybeOrValue<Value> result =
2997 thenMethod.As<Function>().Call(*this, {onFulfilled});
2998 if (result.IsJust()) {
2999 return Just(scope.Escape(result.Unwrap()).As<Promise>());
3000 }
3001 return Nothing<Promise>();
3002#else
3003 Function thenMethod = Get("then").As<Function>();
3004 MaybeOrValue<Value> result = thenMethod.Call(*this, {onFulfilled});
3005 if (scope.Env().IsExceptionPending()) {
3006 return Promise();
3007 }
3008 return scope.Escape(result).As<Promise>();
3009#endif
3010}
3011
3012inline MaybeOrValue<Promise> Promise::Then(napi_value onFulfilled,
3013 napi_value onRejected) const {

Calls 8

JustFunction · 0.85
PromiseClass · 0.85
UnwrapToMethod · 0.80
CallMethod · 0.80
IsJustMethod · 0.80
EscapeMethod · 0.80
UnwrapMethod · 0.80
EnvMethod · 0.80

Tested by

no test coverage detected