External (template)

The Napi::External template class implements the ability to create a Napi::Value object with arbitrary C++ data. It is the user's responsibility to manage the memory for the arbitrary C++ data.

Napi::External objects can be created with an optional Finalizer function and optional Hint value. The Finalizer function, if specified, is called when your Napi::External object is released by Node's garbage collector. It gives your code the opportunity to free any dynamically created data. If you specify a Hint value, it is passed to your Finalizer function.

Methods

New

cpp template <typename T> static Napi::External Napi::External::New(napi_env env, T* data);

Returns the created Napi::External<T> object.

New

cpp template <typename T> static Napi::External Napi::External::New(napi_env env, T* data, Finalizer finalizeCallback);

Returns the created Napi::External<T> object.

New

cpp template <typename T> static Napi::External Napi::External::New(napi_env env, T* data, Finalizer finalizeCallback, Hint* finalizeHint);

Returns the created Napi::External<T> object.

Data

cpp T* Napi::External::Data() const;

Returns a pointer to the arbitrary C++ data held by the Napi::External object.