@@ -371,6 +371,8 @@ typedef enum {
371371 napi_closing,
372372 napi_bigint_expected,
373373 napi_date_expected,
374+ napi_arraybuffer_expected,
375+ napi_detachable_arraybuffer_expected,
374376} napi_status;
375377```
376378
@@ -3148,6 +3150,30 @@ Returns `napi_ok` if the API succeeded.
31483150This API represents the invocation of the Strict Equality algorithm as
31493151defined in [Section 7.2.14][] of the ECMAScript Language Specification.
31503152
3153+ ### napi_detach_arraybuffer
3154+ <!-- YAML
3155+ added: REPLACEME
3156+ -->
3157+
3158+ ```C
3159+ napi_status napi_detach_arraybuffer(napi_env env,
3160+ napi_value arraybuffer)
3161+ ```
3162+
3163+ * `[in] env`: The environment that the API is invoked under.
3164+ * `[in] arraybuffer`: The JavaScript `ArrayBuffer` to be detached.
3165+
3166+ Returns `napi_ok` if the API succeeded. If a non-detachable `ArrayBuffer` is
3167+ passed in it returns `napi_detachable_arraybuffer_expected`.
3168+
3169+ Generally, an `ArrayBuffer` is non-detachable if it has been detached before.
3170+ The engine may impose additional conditions on whether an `ArrayBuffer` is
3171+ detachable. For example, V8 requires that the `ArrayBuffer` be external,
3172+ that is, created with [`napi_create_external_arraybuffer`][].
3173+
3174+ This API represents the invocation of the `ArrayBuffer` detach operation as
3175+ defined in [Section 24.1.1.3][] of the ECMAScript Language Specification.
3176+
31513177## Working with JavaScript Properties
31523178
31533179N-API exposes a set of APIs to get and set properties on JavaScript
@@ -5144,6 +5170,7 @@ This API may only be called from the main thread.
51445170[Section 22.1.4.1]: https://tc39.github.io/ecma262/#sec-properties-of-array-instances-length
51455171[Section 22.2]: https://tc39.github.io/ecma262/#sec-typedarray-objects
51465172[Section 24.1]: https://tc39.github.io/ecma262/#sec-arraybuffer-objects
5173+ [Section 24.1.1.3]: https://tc39.es/ecma262/#sec-detacharraybuffer
51475174[Section 24.3]: https://tc39.github.io/ecma262/#sec-dataview-objects
51485175[Section 25.4]: https://tc39.github.io/ecma262/#sec-promise-objects
51495176[`Number.MIN_SAFE_INTEGER`]: https://tc39.github.io/ecma262/#sec-number.min_safe_integer
0 commit comments