From 15fd5b86a6e8711d0c2bbbd3a3a04271425ccbc1 Mon Sep 17 00:00:00 2001 From: Rolf Timmermans Date: Thu, 23 Aug 2018 11:36:59 +0200 Subject: [PATCH 1/2] Add Env() to Promise::Deferred. --- napi-inl.h | 4 ++++ napi.h | 1 + 2 files changed, 5 insertions(+) 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; From b309a51f28fd4fdb5979cb76d644c6780f139876 Mon Sep 17 00:00:00 2001 From: Rolf Timmermans Date: Thu, 30 Aug 2018 08:39:10 +0200 Subject: [PATCH 2/2] Add documentation for Env(). --- doc/promises.md | 8 ++++++++ 1 file changed, 8 insertions(+) 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