raw
current commit
210328.2 · doc: rename N-API with Node-API

CallbackScope

There are cases (for example, resolving promises) where it is necessary to have the equivalent of the scope associated with a callback in place when making certain Node-API calls.

Methods

Constructor

Creates a new callback scope on the stack.

Napi::CallbackScope::CallbackScope(napi_env env, napi_callback_scope scope);

Constructor

Creates a new callback scope on the stack.

Napi::CallbackScope::CallbackScope(napi_env env, napi_async_context context);

Destructor

Deletes the instance of Napi::CallbackScope object.

virtual Napi::CallbackScope::~CallbackScope();

Env

Napi::Env Napi::CallbackScope::Env() const;

Returns the Napi::Env associated with the Napi::CallbackScope.

Operator

Napi::CallbackScope::operator napi_callback_scope() const;

Returns the Node-API napi_callback_scope wrapped by the Napi::CallbackScope object. This can be used to mix usage of the C Node-API and node-addon-api.