diff --git a/doc/promises.md b/doc/promises.md index f0bf8a61d..e67483bbb 100644 --- a/doc/promises.md +++ b/doc/promises.md @@ -41,6 +41,14 @@ Promise::Deferred(napi_env env); * `[in] env`: The `napi_env` environment in which to construct the Deferred object. +### Env + +```cpp +Napi::Env Env() const; +``` + +Returns the Env environment this Promise::Deferred object is associated with. + ### Promise ```cpp diff --git a/napi-inl.h b/napi-inl.h index 46ba2c0b9..620cac501 100644 --- a/napi-inl.h +++ b/napi-inl.h @@ -1622,6 +1622,10 @@ inline Promise Promise::Deferred::Promise() const { return Napi::Promise(_env, _promise); } +inline Napi::Env Promise::Deferred::Env() const { + return Napi::Env(_env); +} + inline void Promise::Deferred::Resolve(napi_value value) const { napi_status status = napi_resolve_deferred(_env, _deferred, value); NAPI_THROW_IF_FAILED(_env, status); diff --git a/napi.h b/napi.h index f9852968b..531d1c358 100644 --- a/napi.h +++ b/napi.h @@ -881,6 +881,7 @@ namespace Napi { Deferred(napi_env env); Napi::Promise Promise() const; + Napi::Env Env() const; void Resolve(napi_value value) const; void Reject(napi_value value) const;