| 2987 | inline Promise::Promise(napi_env env, napi_value value) : Object(env, value) {} |
| 2988 | |
| 2989 | inline 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 | |
| 3012 | inline MaybeOrValue<Promise> Promise::Then(napi_value onFulfilled, |
| 3013 | napi_value onRejected) const { |
no test coverage detected