• Home
  • Raw
  • Download

Lines Matching refs:API

1 # Node-API
8 Node-API (formerly N-API) is an API for building native Addons. It is
10 maintained as part of Node.js itself. This API will be Application Binary
19 APIs, the functions available in Node-API are used.
21 APIs exposed by Node-API are generally used to create and manipulate
26 * All Node-API calls return a status code of type `napi_status`. This
27 status indicates whether the API call succeeded or failed.
28 * The API's return value is passed via an out parameter.
35 Node-API is a C API that ensures ABI stability across Node.js versions
36 and different compiler levels. A C++ API can be easier to use.
39 This wrapper provides an inlineable C++ API. Binaries built
40 with `node-addon-api` will depend on the symbols for the Node-API C-based
42 efficient way to write code that calls Node-API. Take, for example, the
75 it still gets the benefits of the ABI stability provided by the C API.
77 When using `node-addon-api` instead of the C APIs, start with the API [docs][]
80 The [Node-API Resource](https://nodejs.github.io/node-addon-examples/) offers
82 Node-API and `node-addon-api`.
86 Although Node-API provides an ABI stability guarantee, other parts of Node.js do
106 * the V8 API available via
113 must use Node-API exclusively by restricting itself to using
120 library makes ABI stability guarantees similar to Node-API.
125 native addons using Node-API requires an additional set of tools. Besides the
209 In order to use the Node-API functions, include the file [`node_api.h`][] which
217 In order to ensure compatibility with specific versions of Node-API, the version
225 This restricts the Node-API surface to just the functionality that was available
228 Some of the Node-API surface is experimental and requires explicit opt-in:
235 In this case the entire API surface, including any experimental APIs, will be
238 ## Node-API version matrix
240 Node-API versions are additive and versioned independently from Node.js.
349 \* Node-API was experimental.
351 \*\* Node.js 8.0.0 included Node-API as experimental. It was released as
352 Node-API version 1 but continued to evolve until Node.js 8.6.0. The API is
353 different in versions prior to Node.js 8.6.0. We recommend Node-API version 3 or
356 Each API documented for Node-API will have a header named `added in:`, and APIs
357 which are stable will have the additional header `Node-API version:`.
359 the Node-API version shown in `Node-API version:` or higher.
361 `Node-API version:` listed or if there is no `Node-API version:` listed,
362 then the API will only be available if
364 or `js_native_api.h`. If an API appears not to be available on
372 implementations of Node-API outside of Node.js. For those implementations the
377 latter may be used with multiple implementations of Node-API. In the example
380 implementation of Node-API or any implementation of Node-API outside of Node.js.
481 To this end, Node-API provides a way to allocate data such that its life cycle
499 * `[in] env`: The environment that the Node-API call is invoked under.
507 Returns `napi_ok` if the API succeeded.
509 This API associates `data` with the currently running Agent. `data` can later
528 * `[in] env`: The environment that the Node-API call is invoked under.
532 Returns `napi_ok` if the API succeeded.
534 This API retrieves data that was previously associated with the currently
538 ## Basic Node-API data types
540 Node-API exposes the following fundamental datatypes as abstractions that are
542 introspectable only with other Node-API calls.
549 Integral status code indicating the success or failure of a Node-API call.
580 If additional information is required upon an API returning a failed status,
604 * `error_code`: The Node-API status code that originated with the last error.
610 `napi_env` is used to represent a context that the underlying Node-API
613 making Node-API calls. Specifically, the same `napi_env` that was passed in when
615 nested Node-API calls. Caching the `napi_env` for the purpose of general reuse,
671 ### Node-API memory management types
675 created within a particular scope. In general, Node-API values are created
678 create a new handle scope, Node-API values will be created in the default handle
743 ### Node-API callback types
760 exposed to JavaScript via Node-API. Callback functions should satisfy the
803 Implementations of this function must avoid making Node-API calls that execute
804 JavaScript or interact with JavaScript objects. Node-API calls should be in the
841 Node-API sets up the environment prior to calling this callback, so it is
854 * `[in] env`: The environment to use for API calls, or `NULL` if the thread-safe
863 the callback to convert this native data to JavaScript values (with Node-API
897 Node-API uses both return values and JavaScript exceptions for error handling.
902 All of the Node-API functions share the same error handling pattern. The
903 return type of all API functions is `napi_status`.
945 * `error_code`: Node-API status code for the last error.
948 Node-API call that was made.
966 * `[in] env`: The environment that the API is invoked under.
970 Returns `napi_ok` if the API succeeded.
972 This API retrieves a `napi_extended_error_info` structure with information
976 a Node-API function is called on the same `env`.
982 This API can be called even if there is a pending JavaScript exception.
986 Any Node-API function call may result in a pending JavaScript exception. This is
987 the case for any of the API functions, even those that may not cause the
997 In many cases when a Node-API function is called and an exception is
1000 for all functions. Node-API allows a subset of the functions to be
1011 code where the native method was invoked. The behavior of most Node-API calls
1044 SemVer applying. In order to support this model with Node-API, both
1074 * `[in] env`: The environment that the API is invoked under.
1077 Returns `napi_ok` if the API succeeded.
1079 This API throws the JavaScript value provided.
1093 * `[in] env`: The environment that the API is invoked under.
1097 Returns `napi_ok` if the API succeeded.
1099 This API throws a JavaScript `Error` with the text provided.
1113 * `[in] env`: The environment that the API is invoked under.
1117 Returns `napi_ok` if the API succeeded.
1119 This API throws a JavaScript `TypeError` with the text provided.
1133 * `[in] env`: The environment that the API is invoked under.
1137 Returns `napi_ok` if the API succeeded.
1139 This API throws a JavaScript `RangeError` with the text provided.
1153 * `[in] env`: The environment that the API is invoked under.
1158 Returns `napi_ok` if the API succeeded.
1160 This API queries a `napi_value` to check if it represents an error object.
1175 * `[in] env`: The environment that the API is invoked under.
1182 Returns `napi_ok` if the API succeeded.
1184 This API returns a JavaScript `Error` with the text provided.
1199 * `[in] env`: The environment that the API is invoked under.
1206 Returns `napi_ok` if the API succeeded.
1208 This API returns a JavaScript `TypeError` with the text provided.
1223 * `[in] env`: The environment that the API is invoked under.
1230 Returns `napi_ok` if the API succeeded.
1232 This API returns a JavaScript `RangeError` with the text provided.
1245 * `[in] env`: The environment that the API is invoked under.
1248 Returns `napi_ok` if the API succeeded.
1250 This API can be called even if there is a pending JavaScript exception.
1262 * `[in] env`: The environment that the API is invoked under.
1265 Returns `napi_ok` if the API succeeded.
1267 This API can be called even if there is a pending JavaScript exception.
1279 * `[in] env`: The environment that the API is invoked under.
1312 This API can be called even if there is a pending JavaScript exception.
1316 As Node-API calls are made, handles to objects in the heap for the underlying
1330 The sections which follow describe the Node-API functions that can be used
1354 To handle this case, Node-API provides the ability to establish a new 'scope' to
1360 Node-API only supports a single nested hierarchy of scopes. There is only one
1391 inner scope needs to live beyond the lifespan of that scope. Node-API supports
1415 * `[in] env`: The environment that the API is invoked under.
1418 Returns `napi_ok` if the API succeeded.
1420 This API opens a new scope.
1433 * `[in] env`: The environment that the API is invoked under.
1436 Returns `napi_ok` if the API succeeded.
1438 This API closes the scope passed in. Scopes must be closed in the
1441 This API can be called even if there is a pending JavaScript exception.
1455 * `[in] env`: The environment that the API is invoked under.
1458 Returns `napi_ok` if the API succeeded.
1460 This API opens a new scope from which one object can be promoted
1475 * `[in] env`: The environment that the API is invoked under.
1478 Returns `napi_ok` if the API succeeded.
1480 This API closes the scope passed in. Scopes must be closed in the
1483 This API can be called even if there is a pending JavaScript exception.
1498 * `[in] env`: The environment that the API is invoked under.
1505 Returns `napi_ok` if the API succeeded.
1507 This API promotes the handle to the JavaScript object so that it is valid
1511 This API can be called even if there is a pending JavaScript exception.
1525 Node-API provides methods to create persistent references to an object.
1565 * `[in] env`: The environment that the API is invoked under.
1571 Returns `napi_ok` if the API succeeded.
1573 This API create a new reference with the specified reference count
1586 * `[in] env`: The environment that the API is invoked under.
1589 Returns `napi_ok` if the API succeeded.
1591 This API deletes the reference passed in.
1593 This API can be called even if there is a pending JavaScript exception.
1607 * `[in] env`: The environment that the API is invoked under.
1611 Returns `napi_ok` if the API succeeded.
1613 This API increments the reference count for the reference
1628 * `[in] env`: The environment that the API is invoked under.
1632 Returns `napi_ok` if the API succeeded.
1634 This API decrements the reference count for the reference
1652 * `[in] env`: The environment that the API is invoked under.
1657 Returns `napi_ok` if the API succeeded.
1659 If still valid, this API returns the `napi_value` representing the
1669 Node-API provides functions for registering and un-registering such callbacks.
1741 * `[in] env`: The environment that the API is invoked under.
1784 Node-API modules are registered in a manner similar to other modules
1792 The next difference is the signature for the `Init` method. For a Node-API
1802 exported by the module. Node-API modules cannot modify the `module` object but
1885 All Node-API addons are context-aware, meaning they may be loaded multiple
1896 API.
1899 Node-API exposes a set of APIs to create all types of JavaScript values.
1906 2. Convert from a primitive C type to a Node-API value
1907 3. Convert from Node-API value to a primitive C type
1910 Node-API values are represented by the type `napi_value`.
1911 Any Node-API call that requires a JavaScript value takes in a `napi_value`.
1912 In some cases, the API does check the type of the `napi_value` up-front.
1914 the `napi_value` in question is of the JavaScript type expected by the API.
2039 * `[in] env`: The environment that the Node-API call is invoked under.
2042 Returns `napi_ok` if the API succeeded.
2044 This API returns a Node-API value corresponding to a JavaScript `Array` type.
2060 * `[in] env`: The environment that the API is invoked under.
2064 Returns `napi_ok` if the API succeeded.
2066 This API returns a Node-API value corresponding to a JavaScript `Array` type.
2090 * `[in] env`: The environment that the API is invoked under.
2095 Returns `napi_ok` if the API succeeded.
2097 This API returns a Node-API value corresponding to a JavaScript `ArrayBuffer`.
2123 * `[in] env`: The environment that the API is invoked under.
2128 Returns `napi_ok` if the API succeeded.
2130 This API allocates a `node::Buffer` object. While this is still a
2147 * `[in] env`: The environment that the API is invoked under.
2154 Returns `napi_ok` if the API succeeded.
2156 This API allocates a `node::Buffer` object and initializes it with data copied
2174 * `[in] env`: The environment that the API is invoked under.
2178 Returns `napi_ok` if the API succeeded.
2180 This API does not observe leap seconds; they are ignored, as
2183 This API allocates a JavaScript `Date` object.
2202 * `[in] env`: The environment that the API is invoked under.
2210 Returns `napi_ok` if the API succeeded.
2212 This API allocates a JavaScript value with external data attached to it. This
2216 The API adds a `napi_finalize` callback which will be called when the JavaScript
2222 * the object created by the API can be used with `napi_wrap()`.
2244 * `[in] env`: The environment that the API is invoked under.
2254 Returns `napi_ok` if the API succeeded.
2269 This API returns a Node-API value corresponding to a JavaScript `ArrayBuffer`.
2274 The API adds a `napi_finalize` callback which will be called when the JavaScript
2280 * the object created by the API can be used with `napi_wrap()`.
2300 * `[in] env`: The environment that the API is invoked under.
2310 Returns `napi_ok` if the API succeeded.
2325 This API allocates a `node::Buffer` object and initializes it with data
2329 The API adds a `napi_finalize` callback which will be called when the JavaScript
2335 * the object created by the API can be used with `napi_wrap()`.
2349 * `[in] env`: The environment that the API is invoked under.
2352 Returns `napi_ok` if the API succeeded.
2354 This API allocates a default JavaScript `Object`.
2372 * `[in] env`: The environment that the API is invoked under.
2377 Returns `napi_ok` if the API succeeded.
2379 This API creates a JavaScript `symbol` value from a UTF8-encoded C string.
2399 * `[in] env`: The environment that the API is invoked under.
2407 Returns `napi_ok` if the API succeeded.
2409 This API creates a JavaScript `TypedArray` object over an existing
2435 * `[in] env`: The environment that the API is invoked under.
2442 Returns `napi_ok` if the API succeeded.
2444 This API creates a JavaScript `DataView` object over an existing `ArrayBuffer`.
2455 ### Functions to convert from C types to Node-API
2466 * `[in] env`: The environment that the API is invoked under.
2470 Returns `napi_ok` if the API succeeded.
2472 This API is used to convert from the C `int32_t` type to the JavaScript
2488 * `[in] env`: The environment that the API is invoked under.
2492 Returns `napi_ok` if the API succeeded.
2494 This API is used to convert from the C `uint32_t` type to the JavaScript
2510 * `[in] env`: The environment that the API is invoked under.
2514 Returns `napi_ok` if the API succeeded.
2516 This API is used to convert from the C `int64_t` type to the JavaScript
2535 * `[in] env`: The environment that the API is invoked under.
2539 Returns `napi_ok` if the API succeeded.
2541 This API is used to convert from the C `double` type to the JavaScript
2559 * `[in] env`: The environment that the API is invoked under.
2563 Returns `napi_ok` if the API succeeded.
2565 This API converts the C `int64_t` type to the JavaScript `BigInt` type.
2579 * `[in] env`: The environment that the API is invoked under.
2583 Returns `napi_ok` if the API succeeded.
2585 This API converts the C `uint64_t` type to the JavaScript `BigInt` type.
2601 * `[in] env`: The environment that the API is invoked under.
2608 Returns `napi_ok` if the API succeeded.
2610 This API converts an array of unsigned 64-bit words into a single `BigInt`
2629 * `[in] env`: The environment that the API is invoked under.
2635 Returns `napi_ok` if the API succeeded.
2637 This API creates a JavaScript `string` value from an ISO-8859-1-encoded C
2656 * `[in] env`: The environment that the API is invoked under.
2662 Returns `napi_ok` if the API succeeded.
2664 This API creates a JavaScript `string` value from a UTF16-LE-encoded C string.
2683 * `[in] env`: The environment that the API is invoked under.
2689 Returns `napi_ok` if the API succeeded.
2691 This API creates a JavaScript `string` value from a UTF8-encoded C string.
2697 ### Functions to convert from Node-API to C types
2710 * `[in] env`: The environment that the API is invoked under.
2715 Returns `napi_ok` if the API succeeded.
2717 This API returns the length of an array.
2735 * `[in] env`: The environment that the API is invoked under.
2741 Returns `napi_ok` if the API succeeded.
2743 This API is used to retrieve the underlying data buffer of an `ArrayBuffer` and
2746 *WARNING*: Use caution while using this API. The lifetime of the underlying data
2748 possible safe way to use this API is in conjunction with
2767 * `[in] env`: The environment that the API is invoked under.
2773 Returns `napi_ok` if the API succeeded.
2775 This API is used to retrieve the underlying data buffer of a `node::Buffer`
2778 *Warning*: Use caution while using this API since the underlying data buffer's
2793 * `[in] env`: The environment that the API is invoked under.
2799 Returns `napi_ok` if the API succeeded.
2817 * `[in] env`: The environment that the API is invoked under.
2833 Returns `napi_ok` if the API succeeded.
2835 This API returns various properties of a typed array.
2837 *Warning*: Use caution while using this API since the underlying data buffer
2855 * `[in] env`: The environment that the API is invoked under.
2865 Returns `napi_ok` if the API succeeded.
2867 This API returns various properties of a `DataView`.
2883 * `[in] env`: The environment that the API is invoked under.
2888 This API does not observe leap seconds; they are ignored, as
2891 Returns `napi_ok` if the API succeeded. If a non-date `napi_value` is passed
2894 This API returns the C double primitive of time value for the given JavaScript
2907 * `[in] env`: The environment that the API is invoked under.
2912 Returns `napi_ok` if the API succeeded. If a non-boolean `napi_value` is
2915 This API returns the C boolean primitive equivalent of the given JavaScript
2930 * `[in] env`: The environment that the API is invoked under.
2935 Returns `napi_ok` if the API succeeded. If a non-number `napi_value` is passed
2938 This API returns the C double primitive equivalent of the given JavaScript
2954 * `[in] env`: The environment that the API is invoked under
2961 Returns `napi_ok` if the API succeeded. If a non-`BigInt` is passed in it
2964 This API returns the C `int64_t` primitive equivalent of the given JavaScript
2980 * `[in] env`: The environment that the API is invoked under.
2987 Returns `napi_ok` if the API succeeded. If a non-`BigInt` is passed in it
2990 This API returns the C `uint64_t` primitive equivalent of the given JavaScript
3007 * `[in] env`: The environment that the API is invoked under.
3016 Returns `napi_ok` if the API succeeded.
3018 This API converts a single `BigInt` value into a sign bit, 64-bit little-endian
3034 * `[in] env`: The environment that the API is invoked under.
3038 Returns `napi_ok` if the API succeeded. If a non-external `napi_value` is
3041 This API retrieves the external data pointer that was previously passed to
3056 * `[in] env`: The environment that the API is invoked under.
3061 Returns `napi_ok` if the API succeeded. If a non-number `napi_value`
3064 This API returns the C `int32` primitive equivalent
3086 * `[in] env`: The environment that the API is invoked under.
3091 Returns `napi_ok` if the API succeeded. If a non-number `napi_value`
3094 This API returns the C `int64` primitive equivalent of the given JavaScript
3118 * `[in] env`: The environment that the API is invoked under.
3128 Returns `napi_ok` if the API succeeded. If a non-`string` `napi_value`
3131 This API returns the ISO-8859-1-encoded string corresponding the value passed
3148 * `[in] env`: The environment that the API is invoked under.
3158 Returns `napi_ok` if the API succeeded. If a non-`string` `napi_value`
3161 This API returns the UTF8-encoded string corresponding the value passed in.
3177 * `[in] env`: The environment that the API is invoked under.
3187 Returns `napi_ok` if the API succeeded. If a non-`string` `napi_value`
3190 This API returns the UTF16-encoded string corresponding the value passed in.
3204 * `[in] env`: The environment that the API is invoked under.
3209 Returns `napi_ok` if the API succeeded. If a non-number `napi_value`
3212 This API returns the C primitive equivalent of the given `napi_value` as a
3226 * `[in] env`: The environment that the API is invoked under.
3231 Returns `napi_ok` if the API succeeded.
3233 This API is used to return the JavaScript singleton object that is used to
3246 * `[in] env`: The environment that the API is invoked under.
3249 Returns `napi_ok` if the API succeeded.
3251 This API returns the `global` object.
3263 * `[in] env`: The environment that the API is invoked under.
3266 Returns `napi_ok` if the API succeeded.
3268 This API returns the `null` object.
3280 * `[in] env`: The environment that the API is invoked under.
3283 Returns `napi_ok` if the API succeeded.
3285 This API returns the Undefined object.
3289 Node-API exposes a set of APIs to perform some abstract operations on JavaScript
3312 * `[in] env`: The environment that the API is invoked under.
3316 Returns `napi_ok` if the API succeeded.
3318 This API implements the abstract operation `ToBoolean()` as defined in
3320 This API can be re-entrant if getters are defined on the passed-in `Object`.
3334 * `[in] env`: The environment that the API is invoked under.
3338 Returns `napi_ok` if the API succeeded.
3340 This API implements the abstract operation `ToNumber()` as defined in
3342 This API can be re-entrant if getters are defined on the passed-in `Object`.
3356 * `[in] env`: The environment that the API is invoked under.
3360 Returns `napi_ok` if the API succeeded.
3362 This API implements the abstract operation `ToObject()` as defined in
3364 This API can be re-entrant if getters are defined on the passed-in `Object`.
3378 * `[in] env`: The environment that the API is invoked under.
3382 Returns `napi_ok` if the API succeeded.
3384 This API implements the abstract operation `ToString()` as defined in
3386 This API can be re-entrant if getters are defined on the passed-in `Object`.
3398 * `[in] env`: The environment that the API is invoked under.
3402 Returns `napi_ok` if the API succeeded.
3407 This API represents behavior similar to invoking the `typeof` Operator on
3430 * `[in] env`: The environment that the API is invoked under.
3437 Returns `napi_ok` if the API succeeded.
3439 This API represents invoking the `instanceof` Operator on the object as
3452 * `[in] env`: The environment that the API is invoked under.
3456 Returns `napi_ok` if the API succeeded.
3458 This API represents invoking the `IsArray` operation on the object
3471 * `[in] env`: The environment that the API is invoked under.
3475 Returns `napi_ok` if the API succeeded.
3477 This API checks if the `Object` passed in is an array buffer.
3489 * `[in] env`: The environment that the API is invoked under.
3494 Returns `napi_ok` if the API succeeded.
3496 This API checks if the `Object` passed in is a buffer.
3510 * `[in] env`: The environment that the API is invoked under.
3515 Returns `napi_ok` if the API succeeded.
3517 This API checks if the `Object` passed in is a date.
3529 * `[in] env`: The environment that the API is invoked under.
3533 Returns `napi_ok` if the API succeeded.
3535 This API checks if the `Object` passed in is an `Error`.
3547 * `[in] env`: The environment that the API is invoked under.
3551 Returns `napi_ok` if the API succeeded.
3553 This API checks if the `Object` passed in is a typed array.
3565 * `[in] env`: The environment that the API is invoked under.
3569 Returns `napi_ok` if the API succeeded.
3571 This API checks if the `Object` passed in is a `DataView`.
3586 * `[in] env`: The environment that the API is invoked under.
3591 Returns `napi_ok` if the API succeeded.
3593 This API represents the invocation of the Strict Equality algorithm as
3610 * `[in] env`: The environment that the API is invoked under.
3613 Returns `napi_ok` if the API succeeded. If a non-detachable `ArrayBuffer` is
3621 This API represents the invocation of the `ArrayBuffer` detach operation as
3639 * `[in] env`: The environment that the API is invoked under.
3643 Returns `napi_ok` if the API succeeded.
3647 This API represents the invocation of the `ArrayBuffer` `IsDetachedBuffer`
3653 Node-API exposes a set of APIs to get and set properties on JavaScript
3658 Fundamentally, all property keys in Node-API can be represented in one of the
3663 * JavaScript value: these are represented in Node-API by `napi_value`. This can
3666 Node-API values are represented by the type `napi_value`.
3667 Any Node-API call that requires a JavaScript value takes in a `napi_value`.
3669 `napi_value` in question is of the JavaScript type expected by the API.
3682 The equivalent can be done using Node-API values with the following snippet:
3709 The equivalent can be done using Node-API values with the following snippet:
3736 The following is the approximate equivalent of the Node-API counterpart:
3762 The following is the approximate equivalent of the Node-API counterpart:
3872 performed using a Node-API call). [`napi_callback`][] provides more details.
3877 performed using a Node-API call). [`napi_callback`][] provides more details.
3900 * `[in] env`: The environment that the Node-API call is invoked under.
3903 that represent the property names of the object. The API can be used to
3907 Returns `napi_ok` if the API succeeded.
3909 This API returns the names of the enumerable properties of `object` as an array
3930 * `[in] env`: The environment that the Node-API call is invoked under.
3940 Returns `napi_ok` if the API succeeded.
3942 This API returns an array containing the names of the available properties
3958 * `[in] env`: The environment that the Node-API call is invoked under.
3963 Returns `napi_ok` if the API succeeded.
3965 This API set a property on the `Object` passed in.
3980 * `[in] env`: The environment that the Node-API call is invoked under.
3985 Returns `napi_ok` if the API succeeded.
3987 This API gets the requested property from the `Object` passed in.
4002 * `[in] env`: The environment that the Node-API call is invoked under.
4007 Returns `napi_ok` if the API succeeded.
4009 This API checks if the `Object` passed in has the named property.
4024 * `[in] env`: The environment that the Node-API call is invoked under.
4030 Returns `napi_ok` if the API succeeded.
4032 This API attempts to delete the `key` own property from `object`.
4047 * `[in] env`: The environment that the Node-API call is invoked under.
4052 Returns `napi_ok` if the API succeeded.
4054 This API checks if the `Object` passed in has the named own property. `key` must
4055 be a `string` or a `symbol`, or an error will be thrown. Node-API will not
4071 * `[in] env`: The environment that the Node-API call is invoked under.
4076 Returns `napi_ok` if the API succeeded.
4094 * `[in] env`: The environment that the Node-API call is invoked under.
4099 Returns `napi_ok` if the API succeeded.
4117 * `[in] env`: The environment that the Node-API call is invoked under.
4122 Returns `napi_ok` if the API succeeded.
4140 * `[in] env`: The environment that the Node-API call is invoked under.
4145 Returns `napi_ok` if the API succeeded.
4147 This API sets and element on the `Object` passed in.
4162 * `[in] env`: The environment that the Node-API call is invoked under.
4167 Returns `napi_ok` if the API succeeded.
4169 This API gets the element at the requested index.
4184 * `[in] env`: The environment that the Node-API call is invoked under.
4189 Returns `napi_ok` if the API succeeded.
4191 This API returns if the `Object` passed in has an element at the
4207 * `[in] env`: The environment that the Node-API call is invoked under.
4213 Returns `napi_ok` if the API succeeded.
4215 This API attempts to delete the specified `index` from `object`.
4230 * `[in] env`: The environment that the Node-API call is invoked under.
4235 Returns `napi_ok` if the API succeeded.
4240 this API will set the properties on the object one at a time, as defined by
4257 * `[in] env`: The environment that the Node-API call is invoked under.
4260 Returns `napi_ok` if the API succeeded.
4283 * `[in] env`: The environment that the Node-API call is invoked under.
4286 Returns `napi_ok` if the API succeeded.
4295 Node-API provides a set of APIs that allow JavaScript code to
4307 Additionally, Node-API provides a set of functions which allow calling
4312 Any non-`NULL` data which is passed to this API via the `data` field of the
4332 * `[in] env`: The environment that the API is invoked under.
4340 Returns `napi_ok` if the API succeeded.
4401 * `[in] env`: The environment that the API is invoked under.
4413 Returns `napi_ok` if the API succeeded.
4415 This API allows an add-on author to create a function object in native code.
4459 Any non-`NULL` data which is passed to this API via the `data` parameter can
4482 * `[in] env`: The environment that the API is invoked under.
4494 Returns `napi_ok` if the API succeeded.
4511 * `[in] env`: The environment that the API is invoked under.
4515 Returns `napi_ok` if the API succeeded.
4517 This API returns the `new.target` of the constructor call. If the current
4534 * `[in] env`: The environment that the API is invoked under.
4556 The following can be approximated in Node-API using the following snippet:
4578 Returns `napi_ok` if the API succeeded.
4582 Node-API offers a way to "wrap" C++ classes and instances so that the class
4585 1. The [`napi_define_class`][] API defines a JavaScript class with constructor,
4669 To this end, Node-API provides type-tagging capabilities.
4671 A type tag is a 128-bit integer unique to the addon. Node-API provides the
4771 * `[in] env`: The environment that the API is invoked under.
4790 Returns `napi_ok` if the API succeeded.
4820 Any non-`NULL` data which is passed to this API via the `data` parameter or via
4841 * `[in] env`: The environment that the API is invoked under.
4853 Returns `napi_ok` if the API succeeded.
4896 * `[in] env`: The environment that the API is invoked under.
4900 Returns `napi_ok` if the API succeeded.
4923 * `[in] env`: The environment that the API is invoked under.
4927 Returns `napi_ok` if the API succeeded.
4948 * `[in] env`: The environment that the API is invoked under.
4952 Returns `napi_ok` if the API succeeded.
4959 If the object already has an associated type tag, this API will return
4977 * `[in] env`: The environment that the API is invoked under.
4983 Returns `napi_ok` if the API succeeded.
5006 * `[in] env`: The environment that the API is invoked under.
5018 Returns `napi_ok` if the API succeeded.
5021 in `js_object` is ready for garbage collection. This API is similar to
5026 * the API can be called multiple times with different data items in order to
5028 * the object manipulated by the API can be used with `napi_wrap()`.
5043 Node-API provides an ABI-stable interface for these
5046 Node-API defines the `napi_async_work` structure which is used to manage
5054 The `execute` function should avoid making any Node-API calls
5056 JavaScript objects. Most often, any code that needs to make Node-API
5111 * `[in] env`: The environment that the API is invoked under.
5115 provided for diagnostic information exposed by the `async_hooks` API.
5128 Returns `napi_ok` if the API succeeded.
5130 This API allocates a work object that is used to execute logic asynchronously.
5152 * `[in] env`: The environment that the API is invoked under.
5155 Returns `napi_ok` if the API succeeded.
5157 This API frees a previously allocated work object.
5159 This API can be called even if there is a pending JavaScript exception.
5172 * `[in] env`: The environment that the API is invoked under.
5175 Returns `napi_ok` if the API succeeded.
5177 This API requests that the previously allocated work be scheduled
5178 for execution. Once it returns successfully, this API must not be called again
5192 * `[in] env`: The environment that the API is invoked under.
5195 Returns `napi_ok` if the API succeeded.
5197 This API cancels queued work if it has not yet
5204 This API can be called even if there is a pending JavaScript exception.
5226 * `[in] env`: The environment that the API is invoked under.
5231 provided for diagnostic information exposed by the `async_hooks` API.
5234 Returns `napi_ok` if the API succeeded.
5237 [`napi_async_destroy`][] to keep `async_hooks` related API acts correctly. In
5244 problems like loss of async context when using the `AsyncLocalStoage` API.
5264 * `[in] env`: The environment that the API is invoked under.
5267 Returns `napi_ok` if the API succeeded.
5269 This API can be called even if there is a pending JavaScript exception.
5291 * `[in] env`: The environment that the API is invoked under.
5298 async context when using the `AsyncLocalStorage` API.
5306 Returns `napi_ok` if the API succeeded.
5309 add-on. This API is similar to `napi_call_function`. However, it is used to call
5337 * `[in] env`: The environment that the API is invoked under.
5348 in place when making certain Node-API calls. If there is no other script on
5364 * `[in] env`: The environment that the API is invoked under.
5367 This API can be called even if there is a pending JavaScript exception.
5389 * `[in] env`: The environment that the API is invoked under.
5392 Returns `napi_ok` if the API succeeded.
5411 * `[in] env`: The environment that the API is invoked under.
5412 * `[out] result`: The highest version of Node-API supported.
5414 Returns `napi_ok` if the API succeeded.
5416 This API returns the highest Node-API version supported by the
5417 Node.js runtime. Node-API is planned to be additive such that
5418 newer releases of Node.js may support additional API functions.
5424 * Call `napi_get_version()` to determine if the API is available.
5444 * `[in] env`: The environment that the API is invoked under.
5449 Returns `napi_ok` if the API succeeded.
5459 Node-API provides facilities for creating `Promise` objects as described in
5525 * `[in] env`: The environment that the API is invoked under.
5531 Returns `napi_ok` if the API succeeded.
5533 This API creates a deferred object and a JavaScript promise.
5547 * `[in] env`: The environment that the API is invoked under.
5551 This API resolves a JavaScript promise by way of the deferred object
5556 have been retained in order to be passed to this API.
5572 * `[in] env`: The environment that the API is invoked under.
5576 This API rejects a JavaScript promise by way of the deferred object
5581 have been retained in order to be passed to this API.
5597 * `[in] env`: The environment that the API is invoked under.
5604 Node-API provides an API for executing a string containing JavaScript using the
5619 * `[in] env`: The environment that the API is invoked under.
5638 Node-API provides a function for getting the current event loop associated with
5654 * `[in] env`: The environment that the API is invoked under.
5660 thread. If an addon creates additional threads, then Node-API functions that
5694 whether the API behaves blockingly. If set to `napi_tsfn_nonblocking`, the API
5697 `napi_tsfn_blocking`, the API blocks until space becomes available in the queue.
5713 created by one of the secondary threads. The callback can then use an API such
5722 Node-API runs `call_js_cb` in a context appropriate for callbacks.
5738 should be the last API call made in conjunction with a given
5752 `napi_acquire_threadsafe_function()`. In fact, all subsequent API calls
5809 * `[in] env`: The environment that the API is invoked under.
5816 by the `async_hooks` API.
5849 This API may be called from any thread which makes use of `func`.
5882 This API should not be called with `napi_tsfn_blocking` from a JavaScript
5886 This API will return `napi_closing` if `napi_release_threadsafe_function()` was
5888 added to the queue if the API returns `napi_ok`.
5890 This API may be called from any thread which makes use of `func`.
5907 A thread should call this API before passing `func` to any other thread-safe
5912 This API may be called from any thread which will start making use of `func`.
5937 A thread should call this API when it stops making use of `func`. Passing `func`
5938 to any thread-safe APIs after having called this API has undefined results, as
5941 This API may be called from any thread which will stop making use of `func`.
5955 * `[in] env`: The environment that the API is invoked under.
5958 This API is used to indicate that the event loop running on the main thread
5967 This API may only be called from the main thread.
5981 * `[in] env`: The environment that the API is invoked under.
5984 This API is used to indicate that the event loop running on the main thread
5988 This API may only be called from the main thread.
6006 * `[in] env`: The environment that the API is invoked under.