Basic Node-API data types
Source: Node.js documentationNode-API exposes the following fundamental data types as abstractions that are consumed by the various APIs. These APIs should be treated as opaque, introspectable only with other Node-API calls.
Node-API memory management types
Node-API callback types
APIs in this section
Basic Node-API data types
napi_statusv1Integral status code indicating the success or failure of a Node-API call. Currently, the following status codes are supported.napi_extended_error_infov1See the Error handling section for additional information.napi_envnapi_env is used to represent a context that the underlying Node-API implementation can use to persist VM-specific state.node_api_basic_envexperimentalThis variant of napi_env is passed to synchronous finalizers (node_api_basic_finalize). There is a subset of Node-APIs which accept a parameter of type node_api_basic_env as their first argument.napi_valueThis is an opaque pointer that is used to represent a JavaScript value.napi_threadsafe_functionv4This is an opaque pointer that represents a JavaScript function which can be called asynchronously from multiple threads via napi_call_threadsafe_function().napi_threadsafe_function_release_modev4A value to be given to napi_release_threadsafe_function() to indicate whether the thread-safe function is to be closed immediately (napi_tsfn_abort) or merely released (napi_tsfn_release) and thus available for…napi_threadsafe_function_call_modev4A value to be given to napi_call_threadsafe_function() to indicate whether the call should block whenever the queue associated with the thread-safe function is full.
Node-API memory management types
napi_handle_scopeThis is an abstraction used to control and modify the lifetime of objects created within a particular scope. In general, Node-API values are created within the context of a handle scope.napi_escapable_handle_scopev1Escapable handle scopes are a special type of handle scope to return values created within a particular handle scope to a parent scope.napi_refv1This is the abstraction to use to reference a napi_value. This allows for users to manage the lifetimes of JavaScript values, including defining their minimum lifetimes explicitly.napi_type_tagv8A 128-bit value stored as two unsigned 64-bit integers. It serves as a UUID with which JavaScript objects or externals can be "tagged" in order to ensure that they are of a certain type.napi_async_cleanup_hook_handleAn opaque value returned by napi_add_async_cleanup_hook. It must be passed to napi_remove_async_cleanup_hook when the chain of asynchronous cleanup events completes.
Node-API callback types
napi_callback_infov1Opaque datatype that is passed to a callback function. It can be used for getting additional information about the context in which the callback was invoked.napi_callbackv1Function pointer type for user-provided native functions which are to be exposed to JavaScript via Node-API. Callback functions should satisfy the following signature:node_api_basic_finalizeexperimentalFunction pointer type for add-on provided functions that allow the user to be notified when externally-owned data is ready to be cleaned up because the object it was associated with has been garbage-collected.napi_finalizev1Function pointer type for add-on provided function that allow the user to schedule a group of calls to Node-APIs in response to a garbage collection event, after the garbage collection cycle has completed.napi_async_execute_callbackv1Function pointer used with functions that support asynchronous operations. Callback functions must satisfy the following signature:napi_async_complete_callbackv1Function pointer used with functions that support asynchronous operations. Callback functions must satisfy the following signature:napi_threadsafe_function_call_jsv4Function pointer used with asynchronous thread-safe function calls. The callback will be called on the main thread.napi_cleanup_hookv3Function pointer used with napi_add_env_cleanup_hook. It will be called when the environment is being torn down.napi_async_cleanup_hookFunction pointer used with napi_add_async_cleanup_hook. It will be called when the environment is being torn down.