Lines Matching refs:API
1 # Node-API
9 Node-API (formerly N-API) is an API for building native Addons. It is
11 maintained as part of Node.js itself. This API will be Application Binary
20 APIs, the functions available in Node-API are used.
22 APIs exposed by Node-API are generally used to create and manipulate
27 * All Node-API calls return a status code of type `napi_status`. This
28 status indicates whether the API call succeeded or failed.
29 * The API's return value is passed via an out parameter.
36 Node-API is a C API that ensures ABI stability across Node.js versions
37 and different compiler levels. A C++ API can be easier to use.
40 This wrapper provides an inlinable C++ API. Binaries built
41 with `node-addon-api` will depend on the symbols for the Node-API C-based
43 efficient way to write code that calls Node-API. Take, for example, the
76 it still gets the benefits of the ABI stability provided by the C API.
78 When using `node-addon-api` instead of the C APIs, start with the API [docs][]
81 The [Node-API Resource](https://nodejs.github.io/node-addon-examples/) offers
83 Node-API and `node-addon-api`. Additional media resources can be found on the
84 [Node-API Media][] page.
88 Although Node-API provides an ABI stability guarantee, other parts of Node.js do
108 * the V8 API available via
115 must use Node-API exclusively by restricting itself to using
122 library makes ABI stability guarantees similar to Node-API.
127 native addons using Node-API requires an additional set of tools. Besides the
211 In order to use the Node-API functions, include the file [`node_api.h`][] which
219 In order to ensure compatibility with specific versions of Node-API, the version
227 This restricts the Node-API surface to just the functionality that was available
230 Some of the Node-API surface is experimental and requires explicit opt-in:
237 In this case the entire API surface, including any experimental APIs, will be
240 ## Node-API version matrix
242 Node-API versions are additive and versioned independently from Node.js.
351 \* Node-API was experimental.
353 \*\* Node.js 8.0.0 included Node-API as experimental. It was released as
354 Node-API version 1 but continued to evolve until Node.js 8.6.0. The API is
355 different in versions prior to Node.js 8.6.0. We recommend Node-API version 3 or
358 Each API documented for Node-API will have a header named `added in:`, and APIs
359 which are stable will have the additional header `Node-API version:`.
361 the Node-API version shown in `Node-API version:` or higher.
363 `Node-API version:` listed or if there is no `Node-API version:` listed,
364 then the API will only be available if
366 or `js_native_api.h`. If an API appears not to be available on
374 implementations of Node-API outside of Node.js. For those implementations the
379 latter may be used with multiple implementations of Node-API. In the example
382 implementation of Node-API or any implementation of Node-API outside of Node.js.
484 To this end, Node-API provides a way to associate data such that its life cycle
503 * `[in] env`: The environment that the Node-API call is invoked under.
511 Returns `napi_ok` if the API succeeded.
513 This API associates `data` with the currently running Node.js environment. `data`
533 * `[in] env`: The environment that the Node-API call is invoked under.
537 Returns `napi_ok` if the API succeeded.
539 This API retrieves data that was previously associated with the currently
543 ## Basic Node-API data types
545 Node-API exposes the following fundamental data types as abstractions that are
547 introspectable only with other Node-API calls.
556 Integral status code indicating the success or failure of a Node-API call.
588 If additional information is required upon an API returning a failed status,
613 * `error_code`: The Node-API status code that originated with the last error.
619 `napi_env` is used to represent a context that the underlying Node-API
622 making Node-API calls. Specifically, the same `napi_env` that was passed in when
624 nested Node-API calls. Caching the `napi_env` for the purpose of general reuse,
683 ### Node-API memory management types
688 created within a particular scope. In general, Node-API values are created
691 create a new handle scope, Node-API values will be created in the default handle
764 ### Node-API callback types
785 exposed to JavaScript via Node-API. Callback functions should satisfy the
819 where it cannot execute JavaScript code, some Node-API calls may return
831 Node-API calls made from a finalizer will return `napi_cannot_run_js` when
849 Implementations of this function must avoid making Node-API calls that execute
850 JavaScript or interact with JavaScript objects. Node-API calls should be in the
890 Node-API sets up the environment prior to calling this callback, so it is
903 * `[in] env`: The environment to use for API calls, or `NULL` if the thread-safe
912 the callback to convert this native data to JavaScript values (with Node-API
967 Node-API uses both return values and JavaScript exceptions for error handling.
972 All of the Node-API functions share the same error handling pattern. The
973 return type of all API functions is `napi_status`.
1015 * `error_code`: Node-API status code for the last error.
1018 Node-API call that was made.
1037 * `[in] env`: The environment that the API is invoked under.
1041 Returns `napi_ok` if the API succeeded.
1043 This API retrieves a `napi_extended_error_info` structure with information
1047 a Node-API function is called on the same `env`. This includes a call to
1052 be overwritten) before another Node-API function was called.
1058 This API can be called even if there is a pending JavaScript exception.
1062 Any Node-API function call may result in a pending JavaScript exception. This is
1063 the case for any of the API functions, even those that may not cause the
1073 In many cases when a Node-API function is called and an exception is
1076 for all functions. Node-API allows a subset of the functions to be
1087 code where the native method was invoked. The behavior of most Node-API calls
1119 SemVer applying. In order to support this model with Node-API, both
1150 * `[in] env`: The environment that the API is invoked under.
1153 Returns `napi_ok` if the API succeeded.
1155 This API throws the JavaScript value provided.
1170 * `[in] env`: The environment that the API is invoked under.
1174 Returns `napi_ok` if the API succeeded.
1176 This API throws a JavaScript `Error` with the text provided.
1191 * `[in] env`: The environment that the API is invoked under.
1195 Returns `napi_ok` if the API succeeded.
1197 This API throws a JavaScript `TypeError` with the text provided.
1212 * `[in] env`: The environment that the API is invoked under.
1216 Returns `napi_ok` if the API succeeded.
1218 This API throws a JavaScript `RangeError` with the text provided.
1235 * `[in] env`: The environment that the API is invoked under.
1239 Returns `napi_ok` if the API succeeded.
1241 This API throws a JavaScript `SyntaxError` with the text provided.
1256 * `[in] env`: The environment that the API is invoked under.
1261 Returns `napi_ok` if the API succeeded.
1263 This API queries a `napi_value` to check if it represents an error object.
1279 * `[in] env`: The environment that the API is invoked under.
1286 Returns `napi_ok` if the API succeeded.
1288 This API returns a JavaScript `Error` with the text provided.
1304 * `[in] env`: The environment that the API is invoked under.
1311 Returns `napi_ok` if the API succeeded.
1313 This API returns a JavaScript `TypeError` with the text provided.
1329 * `[in] env`: The environment that the API is invoked under.
1336 Returns `napi_ok` if the API succeeded.
1338 This API returns a JavaScript `RangeError` with the text provided.
1356 * `[in] env`: The environment that the API is invoked under.
1363 Returns `napi_ok` if the API succeeded.
1365 This API returns a JavaScript `SyntaxError` with the text provided.
1379 * `[in] env`: The environment that the API is invoked under.
1382 Returns `napi_ok` if the API succeeded.
1384 This API can be called even if there is a pending JavaScript exception.
1397 * `[in] env`: The environment that the API is invoked under.
1400 Returns `napi_ok` if the API succeeded.
1402 This API can be called even if there is a pending JavaScript exception.
1415 * `[in] env`: The environment that the API is invoked under.
1449 This API can be called even if there is a pending JavaScript exception.
1453 As Node-API calls are made, handles to objects in the heap for the underlying
1467 The sections which follow describe the Node-API functions that can be used
1492 To handle this case, Node-API provides the ability to establish a new 'scope' to
1498 Node-API only supports a single nested hierarchy of scopes. There is only one
1529 inner scope needs to live beyond the lifespan of that scope. Node-API supports
1554 * `[in] env`: The environment that the API is invoked under.
1557 Returns `napi_ok` if the API succeeded.
1559 This API opens a new scope.
1573 * `[in] env`: The environment that the API is invoked under.
1576 Returns `napi_ok` if the API succeeded.
1578 This API closes the scope passed in. Scopes must be closed in the
1581 This API can be called even if there is a pending JavaScript exception.
1596 * `[in] env`: The environment that the API is invoked under.
1599 Returns `napi_ok` if the API succeeded.
1601 This API opens a new scope from which one object can be promoted
1617 * `[in] env`: The environment that the API is invoked under.
1620 Returns `napi_ok` if the API succeeded.
1622 This API closes the scope passed in. Scopes must be closed in the
1625 This API can be called even if there is a pending JavaScript exception.
1641 * `[in] env`: The environment that the API is invoked under.
1648 Returns `napi_ok` if the API succeeded.
1650 This API promotes the handle to the JavaScript object so that it is valid
1654 This API can be called even if there is a pending JavaScript exception.
1668 Node-API provides methods for creating persistent references to values.
1669 Currently Node-API only allows references to be created for a
1736 * `[in] env`: The environment that the API is invoked under.
1741 Returns `napi_ok` if the API succeeded.
1743 This API creates a new reference with the specified reference count
1757 * `[in] env`: The environment that the API is invoked under.
1760 Returns `napi_ok` if the API succeeded.
1762 This API deletes the reference passed in.
1764 This API can be called even if there is a pending JavaScript exception.
1779 * `[in] env`: The environment that the API is invoked under.
1783 Returns `napi_ok` if the API succeeded.
1785 This API increments the reference count for the reference
1801 * `[in] env`: The environment that the API is invoked under.
1805 Returns `napi_ok` if the API succeeded.
1807 This API decrements the reference count for the reference
1823 * `[in] env`: The environment that the API is invoked under.
1828 Returns `napi_ok` if the API succeeded.
1830 If still valid, this API returns the `napi_value` representing the
1840 Node-API provides functions for registering and un-registering such callbacks.
1917 * `[in] env`: The environment that the API is invoked under.
1982 Node-API modules are registered in a manner similar to other modules
1990 The next difference is the signature for the `Init` method. For a Node-API
2000 exported by the module. Node-API modules cannot modify the `module` object but
2083 All Node-API addons are context-aware, meaning they may be loaded multiple
2094 API.
2098 Node-API exposes a set of APIs to create all types of JavaScript values.
2105 2. Convert from a primitive C type to a Node-API value
2106 3. Convert from Node-API value to a primitive C type
2109 Node-API values are represented by the type `napi_value`.
2110 Any Node-API call that requires a JavaScript value takes in a `napi_value`.
2111 In some cases, the API does check the type of the `napi_value` up-front.
2113 the `napi_value` in question is of the JavaScript type expected by the API.
2247 * `[in] env`: The environment that the Node-API call is invoked under.
2250 Returns `napi_ok` if the API succeeded.
2252 This API returns a Node-API value corresponding to a JavaScript `Array` type.
2269 * `[in] env`: The environment that the API is invoked under.
2273 Returns `napi_ok` if the API succeeded.
2275 This API returns a Node-API value corresponding to a JavaScript `Array` type.
2300 * `[in] env`: The environment that the API is invoked under.
2306 Returns `napi_ok` if the API succeeded.
2308 This API returns a Node-API value corresponding to a JavaScript `ArrayBuffer`.
2335 * `[in] env`: The environment that the API is invoked under.
2341 Returns `napi_ok` if the API succeeded.
2343 This API allocates a `node::Buffer` object. While this is still a
2361 * `[in] env`: The environment that the API is invoked under.
2369 Returns `napi_ok` if the API succeeded.
2371 This API allocates a `node::Buffer` object and initializes it with data copied
2390 * `[in] env`: The environment that the API is invoked under.
2394 Returns `napi_ok` if the API succeeded.
2396 This API does not observe leap seconds; they are ignored, as
2399 This API allocates a JavaScript `Date` object.
2419 * `[in] env`: The environment that the API is invoked under.
2427 Returns `napi_ok` if the API succeeded.
2429 This API allocates a JavaScript value with external data attached to it. This
2433 The API adds a `napi_finalize` callback which will be called when the JavaScript
2457 * `[in] env`: The environment that the API is invoked under.
2467 Returns `napi_ok` if the API succeeded.
2482 This API returns a Node-API value corresponding to a JavaScript `ArrayBuffer`.
2487 The API adds a `napi_finalize` callback which will be called when the JavaScript
2509 * `[in] env`: The environment that the API is invoked under.
2519 Returns `napi_ok` if the API succeeded.
2534 This API allocates a `node::Buffer` object and initializes it with data
2538 The API adds a `napi_finalize` callback which will be called when the JavaScript
2554 * `[in] env`: The environment that the API is invoked under.
2557 Returns `napi_ok` if the API succeeded.
2559 This API allocates a default JavaScript `Object`.
2578 * `[in] env`: The environment that the API is invoked under.
2583 Returns `napi_ok` if the API succeeded.
2585 This API creates a JavaScript `symbol` value from a UTF8-encoded C string.
2604 * `[in] env`: The environment that the API is invoked under.
2611 Returns `napi_ok` if the API succeeded.
2613 This API searches in the global registry for an existing symbol with the given
2636 * `[in] env`: The environment that the API is invoked under.
2644 Returns `napi_ok` if the API succeeded.
2646 This API creates a JavaScript `TypedArray` object over an existing
2673 * `[in] env`: The environment that the API is invoked under.
2680 Returns `napi_ok` if the API succeeded.
2682 This API creates a JavaScript `DataView` object over an existing `ArrayBuffer`.
2693 ### Functions to convert from C types to Node-API
2706 * `[in] env`: The environment that the API is invoked under.
2710 Returns `napi_ok` if the API succeeded.
2712 This API is used to convert from the C `int32_t` type to the JavaScript
2729 * `[in] env`: The environment that the API is invoked under.
2733 Returns `napi_ok` if the API succeeded.
2735 This API is used to convert from the C `uint32_t` type to the JavaScript
2752 * `[in] env`: The environment that the API is invoked under.
2756 Returns `napi_ok` if the API succeeded.
2758 This API is used to convert from the C `int64_t` type to the JavaScript
2778 * `[in] env`: The environment that the API is invoked under.
2782 Returns `napi_ok` if the API succeeded.
2784 This API is used to convert from the C `double` type to the JavaScript
2803 * `[in] env`: The environment that the API is invoked under.
2807 Returns `napi_ok` if the API succeeded.
2809 This API converts the C `int64_t` type to the JavaScript `BigInt` type.
2824 * `[in] env`: The environment that the API is invoked under.
2828 Returns `napi_ok` if the API succeeded.
2830 This API converts the C `uint64_t` type to the JavaScript `BigInt` type.
2847 * `[in] env`: The environment that the API is invoked under.
2854 Returns `napi_ok` if the API succeeded.
2856 This API converts an array of unsigned 64-bit words into a single `BigInt`
2876 * `[in] env`: The environment that the API is invoked under.
2882 Returns `napi_ok` if the API succeeded.
2884 This API creates a JavaScript `string` value from an ISO-8859-1-encoded C
2909 * `[in] env`: The environment that the API is invoked under.
2920 to the API.
2931 Returns `napi_ok` if the API succeeded.
2933 This API creates a JavaScript `string` value from an ISO-8859-1-encoded C
2954 * `[in] env`: The environment that the API is invoked under.
2960 Returns `napi_ok` if the API succeeded.
2962 This API creates a JavaScript `string` value from a UTF16-LE-encoded C string.
2987 * `[in] env`: The environment that the API is invoked under.
2998 to the API.
3009 Returns `napi_ok` if the API succeeded.
3011 This API creates a JavaScript `string` value from a UTF16-LE-encoded C string.
3032 * `[in] env`: The environment that the API is invoked under.
3038 Returns `napi_ok` if the API succeeded.
3040 This API creates a JavaScript `string` value from a UTF8-encoded C string.
3046 ### Functions to convert from Node-API to C types
3061 * `[in] env`: The environment that the API is invoked under.
3066 Returns `napi_ok` if the API succeeded.
3068 This API returns the length of an array.
3087 * `[in] env`: The environment that the API is invoked under.
3093 Returns `napi_ok` if the API succeeded.
3095 This API is used to retrieve the underlying data buffer of an `ArrayBuffer` and
3098 _WARNING_: Use caution while using this API. The lifetime of the underlying data
3100 possible safe way to use this API is in conjunction with
3120 * `[in] env`: The environment that the API is invoked under.
3126 Returns `napi_ok` if the API succeeded.
3128 This API is used to retrieve the underlying data buffer of a `node::Buffer`
3131 _Warning_: Use caution while using this API since the underlying data buffer's
3147 * `[in] env`: The environment that the API is invoked under.
3153 Returns `napi_ok` if the API succeeded.
3172 * `[in] env`: The environment that the API is invoked under.
3188 Returns `napi_ok` if the API succeeded.
3190 This API returns various properties of a typed array.
3194 _Warning_: Use caution while using this API since the underlying data buffer
3213 * `[in] env`: The environment that the API is invoked under.
3223 Returns `napi_ok` if the API succeeded.
3227 This API returns various properties of a `DataView`.
3244 * `[in] env`: The environment that the API is invoked under.
3249 This API does not observe leap seconds; they are ignored, as
3252 Returns `napi_ok` if the API succeeded. If a non-date `napi_value` is passed
3255 This API returns the C double primitive of time value for the given JavaScript
3269 * `[in] env`: The environment that the API is invoked under.
3274 Returns `napi_ok` if the API succeeded. If a non-boolean `napi_value` is
3277 This API returns the C boolean primitive equivalent of the given JavaScript
3293 * `[in] env`: The environment that the API is invoked under.
3298 Returns `napi_ok` if the API succeeded. If a non-number `napi_value` is passed
3301 This API returns the C double primitive equivalent of the given JavaScript
3318 * `[in] env`: The environment that the API is invoked under
3325 Returns `napi_ok` if the API succeeded. If a non-`BigInt` is passed in it
3328 This API returns the C `int64_t` primitive equivalent of the given JavaScript
3345 * `[in] env`: The environment that the API is invoked under.
3352 Returns `napi_ok` if the API succeeded. If a non-`BigInt` is passed in it
3355 This API returns the C `uint64_t` primitive equivalent of the given JavaScript
3373 * `[in] env`: The environment that the API is invoked under.
3382 Returns `napi_ok` if the API succeeded.
3384 This API converts a single `BigInt` value into a sign bit, 64-bit little-endian
3401 * `[in] env`: The environment that the API is invoked under.
3405 Returns `napi_ok` if the API succeeded. If a non-external `napi_value` is
3408 This API retrieves the external data pointer that was previously passed to
3424 * `[in] env`: The environment that the API is invoked under.
3429 Returns `napi_ok` if the API succeeded. If a non-number `napi_value`
3432 This API returns the C `int32` primitive equivalent
3455 * `[in] env`: The environment that the API is invoked under.
3460 Returns `napi_ok` if the API succeeded. If a non-number `napi_value`
3463 This API returns the C `int64` primitive equivalent of the given JavaScript
3488 * `[in] env`: The environment that the API is invoked under.
3498 Returns `napi_ok` if the API succeeded. If a non-`string` `napi_value`
3501 This API returns the ISO-8859-1-encoded string corresponding the value passed
3519 * `[in] env`: The environment that the API is invoked under.
3529 Returns `napi_ok` if the API succeeded. If a non-`string` `napi_value`
3532 This API returns the UTF8-encoded string corresponding the value passed in.
3549 * `[in] env`: The environment that the API is invoked under.
3559 Returns `napi_ok` if the API succeeded. If a non-`string` `napi_value`
3562 This API returns the UTF16-encoded string corresponding the value passed in.
3577 * `[in] env`: The environment that the API is invoked under.
3582 Returns `napi_ok` if the API succeeded. If a non-number `napi_value`
3585 This API returns the C primitive equivalent of the given `napi_value` as a
3601 * `[in] env`: The environment that the API is invoked under.
3606 Returns `napi_ok` if the API succeeded.
3608 This API is used to return the JavaScript singleton object that is used to
3622 * `[in] env`: The environment that the API is invoked under.
3625 Returns `napi_ok` if the API succeeded.
3627 This API returns the `global` object.
3640 * `[in] env`: The environment that the API is invoked under.
3643 Returns `napi_ok` if the API succeeded.
3645 This API returns the `null` object.
3658 * `[in] env`: The environment that the API is invoked under.
3661 Returns `napi_ok` if the API succeeded.
3663 This API returns the Undefined object.
3667 Node-API exposes a set of APIs to perform some abstract operations on JavaScript
3691 * `[in] env`: The environment that the API is invoked under.
3695 Returns `napi_ok` if the API succeeded.
3697 This API implements the abstract operation `ToBoolean()` as defined in
3713 * `[in] env`: The environment that the API is invoked under.
3717 Returns `napi_ok` if the API succeeded.
3719 This API implements the abstract operation `ToNumber()` as defined in
3737 * `[in] env`: The environment that the API is invoked under.
3741 Returns `napi_ok` if the API succeeded.
3743 This API implements the abstract operation `ToObject()` as defined in
3759 * `[in] env`: The environment that the API is invoked under.
3763 Returns `napi_ok` if the API succeeded.
3765 This API implements the abstract operation `ToString()` as defined in
3781 * `[in] env`: The environment that the API is invoked under.
3785 Returns `napi_ok` if the API succeeded.
3790 This API represents behavior similar to invoking the `typeof` Operator on
3814 * `[in] env`: The environment that the API is invoked under.
3821 Returns `napi_ok` if the API succeeded.
3823 This API represents invoking the `instanceof` Operator on the object as
3837 * `[in] env`: The environment that the API is invoked under.
3841 Returns `napi_ok` if the API succeeded.
3843 This API represents invoking the `IsArray` operation on the object
3857 * `[in] env`: The environment that the API is invoked under.
3861 Returns `napi_ok` if the API succeeded.
3863 This API checks if the `Object` passed in is an array buffer.
3876 * `[in] env`: The environment that the API is invoked under.
3881 Returns `napi_ok` if the API succeeded.
3883 This API checks if the `Object` passed in is a buffer.
3898 * `[in] env`: The environment that the API is invoked under.
3903 Returns `napi_ok` if the API succeeded.
3905 This API checks if the `Object` passed in is a date.
3918 * `[in] env`: The environment that the API is invoked under.
3922 Returns `napi_ok` if the API succeeded.
3924 This API checks if the `Object` passed in is an `Error`.
3937 * `[in] env`: The environment that the API is invoked under.
3941 Returns `napi_ok` if the API succeeded.
3943 This API checks if the `Object` passed in is a typed array.
3956 * `[in] env`: The environment that the API is invoked under.
3960 Returns `napi_ok` if the API succeeded.
3962 This API checks if the `Object` passed in is a `DataView`.
3978 * `[in] env`: The environment that the API is invoked under.
3983 Returns `napi_ok` if the API succeeded.
3985 This API represents the invocation of the Strict Equality algorithm as
4003 * `[in] env`: The environment that the API is invoked under.
4006 Returns `napi_ok` if the API succeeded. If a non-detachable `ArrayBuffer` is
4014 This API represents the invocation of the `ArrayBuffer` detach operation as
4033 * `[in] env`: The environment that the API is invoked under.
4037 Returns `napi_ok` if the API succeeded.
4041 This API represents the invocation of the `ArrayBuffer` `IsDetachedBuffer`
4047 Node-API exposes a set of APIs to get and set properties on JavaScript
4052 Fundamentally, all property keys in Node-API can be represented in one of the
4057 * JavaScript value: these are represented in Node-API by `napi_value`. This can
4060 Node-API values are represented by the type `napi_value`.
4061 Any Node-API call that requires a JavaScript value takes in a `napi_value`.
4063 `napi_value` in question is of the JavaScript type expected by the API.
4076 The equivalent can be done using Node-API values with the following snippet:
4103 The equivalent can be done using Node-API values with the following snippet:
4130 The following is the approximate equivalent of the Node-API counterpart:
4156 The following is the approximate equivalent of the Node-API counterpart:
4268 performed using a Node-API call). [`napi_callback`][] provides more details.
4273 performed using a Node-API call). [`napi_callback`][] provides more details.
4298 * `[in] env`: The environment that the Node-API call is invoked under.
4301 that represent the property names of the object. The API can be used to
4305 Returns `napi_ok` if the API succeeded.
4307 This API returns the names of the enumerable properties of `object` as an array
4330 * `[in] env`: The environment that the Node-API call is invoked under.
4340 Returns `napi_ok` if the API succeeded.
4342 This API returns an array containing the names of the available properties
4359 * `[in] env`: The environment that the Node-API call is invoked under.
4364 Returns `napi_ok` if the API succeeded.
4366 This API set a property on the `Object` passed in.
4382 * `[in] env`: The environment that the Node-API call is invoked under.
4387 Returns `napi_ok` if the API succeeded.
4389 This API gets the requested property from the `Object` passed in.
4405 * `[in] env`: The environment that the Node-API call is invoked under.
4410 Returns `napi_ok` if the API succeeded.
4412 This API checks if the `Object` passed in has the named property.
4428 * `[in] env`: The environment that the Node-API call is invoked under.
4434 Returns `napi_ok` if the API succeeded.
4436 This API attempts to delete the `key` own property from `object`.
4452 * `[in] env`: The environment that the Node-API call is invoked under.
4457 Returns `napi_ok` if the API succeeded.
4459 This API checks if the `Object` passed in has the named own property. `key` must
4460 be a `string` or a `symbol`, or an error will be thrown. Node-API will not
4477 * `[in] env`: The environment that the Node-API call is invoked under.
4482 Returns `napi_ok` if the API succeeded.
4501 * `[in] env`: The environment that the Node-API call is invoked under.
4506 Returns `napi_ok` if the API succeeded.
4525 * `[in] env`: The environment that the Node-API call is invoked under.
4530 Returns `napi_ok` if the API succeeded.
4549 * `[in] env`: The environment that the Node-API call is invoked under.
4554 Returns `napi_ok` if the API succeeded.
4556 This API sets an element on the `Object` passed in.
4572 * `[in] env`: The environment that the Node-API call is invoked under.
4577 Returns `napi_ok` if the API succeeded.
4579 This API gets the element at the requested index.
4595 * `[in] env`: The environment that the Node-API call is invoked under.
4600 Returns `napi_ok` if the API succeeded.
4602 This API returns if the `Object` passed in has an element at the
4619 * `[in] env`: The environment that the Node-API call is invoked under.
4625 Returns `napi_ok` if the API succeeded.
4627 This API attempts to delete the specified `index` from `object`.
4643 * `[in] env`: The environment that the Node-API call is invoked under.
4648 Returns `napi_ok` if the API succeeded.
4653 this API will set the properties on the object one at a time, as defined by
4671 * `[in] env`: The environment that the Node-API call is invoked under.
4674 Returns `napi_ok` if the API succeeded.
4698 * `[in] env`: The environment that the Node-API call is invoked under.
4701 Returns `napi_ok` if the API succeeded.
4710 Node-API provides a set of APIs that allow JavaScript code to
4722 Additionally, Node-API provides a set of functions which allow calling
4727 Any non-`NULL` data which is passed to this API via the `data` field of the
4748 * `[in] env`: The environment that the API is invoked under.
4756 Returns `napi_ok` if the API succeeded.
4819 * `[in] env`: The environment that the API is invoked under.
4831 Returns `napi_ok` if the API succeeded.
4833 This API allows an add-on author to create a function object in native code.
4877 Any non-`NULL` data which is passed to this API via the `data` parameter can
4901 * `[in] env`: The environment that the API is invoked under.
4917 Returns `napi_ok` if the API succeeded.
4935 * `[in] env`: The environment that the API is invoked under.
4939 Returns `napi_ok` if the API succeeded.
4941 This API returns the `new.target` of the constructor call. If the current
4959 * `[in] env`: The environment that the API is invoked under.
4982 The following can be approximated in Node-API using the following snippet:
5004 Returns `napi_ok` if the API succeeded.
5008 Node-API offers a way to "wrap" C++ classes and instances so that the class
5011 1. The [`napi_define_class`][] API defines a JavaScript class with constructor,
5095 To this end, Node-API provides type-tagging capabilities.
5097 A type tag is a 128-bit integer unique to the addon. Node-API provides the
5198 * `[in] env`: The environment that the API is invoked under.
5216 Returns `napi_ok` if the API succeeded.
5246 Any non-`NULL` data which is passed to this API via the `data` parameter or via
5268 * `[in] env`: The environment that the API is invoked under.
5280 Returns `napi_ok` if the API succeeded.
5329 * `[in] env`: The environment that the API is invoked under.
5333 Returns `napi_ok` if the API succeeded.
5357 * `[in] env`: The environment that the API is invoked under.
5361 Returns `napi_ok` if the API succeeded.
5383 * `[in] env`: The environment that the API is invoked under.
5387 Returns `napi_ok` if the API succeeded.
5394 If the object already has an associated type tag, this API will return
5413 * `[in] env`: The environment that the API is invoked under.
5420 Returns `napi_ok` if the API succeeded.
5443 * `[in] env`: The environment that the API is invoked under.
5454 Returns `napi_ok` if the API succeeded.
5459 This API can be called multiple times on a single JavaScript object.
5474 Node-API provides an ABI-stable interface for these
5477 Node-API defines the `napi_async_work` structure which is used to manage
5485 The `execute` function should avoid making any Node-API calls
5487 JavaScript objects. Most often, any code that needs to make Node-API
5543 * `[in] env`: The environment that the API is invoked under.
5547 provided for diagnostic information exposed by the `async_hooks` API.
5560 Returns `napi_ok` if the API succeeded.
5562 This API allocates a work object that is used to execute logic asynchronously.
5585 * `[in] env`: The environment that the API is invoked under.
5588 Returns `napi_ok` if the API succeeded.
5590 This API frees a previously allocated work object.
5592 This API can be called even if there is a pending JavaScript exception.
5606 * `[in] env`: The environment that the API is invoked under.
5609 Returns `napi_ok` if the API succeeded.
5611 This API requests that the previously allocated work be scheduled
5612 for execution. Once it returns successfully, this API must not be called again
5627 * `[in] env`: The environment that the API is invoked under.
5630 Returns `napi_ok` if the API succeeded.
5632 This API cancels queued work if it has not yet
5639 This API can be called even if there is a pending JavaScript exception.
5662 * `[in] env`: The environment that the API is invoked under.
5667 provided for diagnostic information exposed by the `async_hooks` API.
5670 Returns `napi_ok` if the API succeeded.
5673 [`napi_async_destroy`][] to keep `async_hooks` related API acts correctly. In
5680 problems like loss of async context when using the `AsyncLocalStorage` API.
5701 * `[in] env`: The environment that the API is invoked under.
5704 Returns `napi_ok` if the API succeeded.
5706 This API can be called even if there is a pending JavaScript exception.
5729 * `[in] env`: The environment that the API is invoked under.
5736 async context when using the `AsyncLocalStorage` API.
5745 Returns `napi_ok` if the API succeeded.
5748 add-on. This API is similar to `napi_call_function`. However, it is used to call
5777 * `[in] env`: The environment that the API is invoked under.
5788 in place when making certain Node-API calls. If there is no other script on
5805 * `[in] env`: The environment that the API is invoked under.
5808 This API can be called even if there is a pending JavaScript exception.
5831 * `[in] env`: The environment that the API is invoked under.
5834 Returns `napi_ok` if the API succeeded.
5854 * `[in] env`: The environment that the API is invoked under.
5855 * `[out] result`: The highest version of Node-API supported.
5857 Returns `napi_ok` if the API succeeded.
5859 This API returns the highest Node-API version supported by the
5860 Node.js runtime. Node-API is planned to be additive such that
5861 newer releases of Node.js may support additional API functions.
5867 * Call `napi_get_version()` to determine if the API is available.
5888 * `[in] env`: The environment that the API is invoked under.
5893 Returns `napi_ok` if the API succeeded.
5903 Node-API provides facilities for creating `Promise` objects as described in
5970 * `[in] env`: The environment that the API is invoked under.
5976 Returns `napi_ok` if the API succeeded.
5978 This API creates a deferred object and a JavaScript promise.
5993 * `[in] env`: The environment that the API is invoked under.
5997 This API resolves a JavaScript promise by way of the deferred object
6002 have been retained in order to be passed to this API.
6019 * `[in] env`: The environment that the API is invoked under.
6023 This API rejects a JavaScript promise by way of the deferred object
6028 have been retained in order to be passed to this API.
6045 * `[in] env`: The environment that the API is invoked under.
6052 Node-API provides an API for executing a string containing JavaScript using the
6068 * `[in] env`: The environment that the API is invoked under.
6087 Node-API provides a function for getting the current event loop associated with
6104 * `[in] env`: The environment that the API is invoked under.
6110 thread. If an addon creates additional threads, then Node-API functions that
6144 whether the API behaves blockingly. If set to `napi_tsfn_nonblocking`, the API
6147 `napi_tsfn_blocking`, the API blocks until space becomes available in the queue.
6163 created by one of the secondary threads. The callback can then use an API such
6172 Node-API runs `call_js_cb` in a context appropriate for callbacks.
6193 should be the last API call made in conjunction with a given
6207 `napi_acquire_threadsafe_function()`. In fact, all subsequent API calls
6264 * `[in] env`: The environment that the API is invoked under.
6271 by the `async_hooks` API.
6304 This API may be called from any thread which makes use of `func`.
6337 This API should not be called with `napi_tsfn_blocking` from a JavaScript
6341 This API will return `napi_closing` if `napi_release_threadsafe_function()` was
6343 added to the queue if the API returns `napi_ok`.
6345 This API may be called from any thread which makes use of `func`.
6362 A thread should call this API before passing `func` to any other thread-safe
6367 This API may be called from any thread which will start making use of `func`.
6392 A thread should call this API when it stops making use of `func`. Passing `func`
6393 to any thread-safe APIs after having called this API has undefined results, as
6396 This API may be called from any thread which will stop making use of `func`.
6410 * `[in] env`: The environment that the API is invoked under.
6413 This API is used to indicate that the event loop running on the main thread
6422 This API may only be called from the main thread.
6436 * `[in] env`: The environment that the API is invoked under.
6439 This API is used to indicate that the event loop running on the main thread
6443 This API may only be called from the main thread.
6463 * `[in] env`: The environment that the API is invoked under.
6484 [Node-API Media]: https://github.com/nodejs/abi-stable-node/blob/HEAD/node-api-media.md