@@ -265,6 +265,8 @@ typedef enum {
265
265
napi_closing,
266
266
napi_bigint_expected,
267
267
napi_date_expected,
268
+ napi_arraybuffer_expected,
269
+ napi_detachable_arraybuffer_expected,
268
270
} napi_status;
269
271
```
270
272
If additional information is required upon an API returning a failed status,
@@ -2946,6 +2948,30 @@ defined in
2946
2948
[Section 7.2.14](https://tc39.github.io/ecma262/#sec-strict-equality-comparison)
2947
2949
of the ECMAScript Language Specification.
2948
2950
2951
+ ### napi_detach_arraybuffer
2952
+ <!-- YAML
2953
+ added: REPLACEME
2954
+ -->
2955
+
2956
+ ```C
2957
+ napi_status napi_detach_arraybuffer(napi_env env,
2958
+ napi_value arraybuffer)
2959
+ ```
2960
+
2961
+ * `[in] env`: The environment that the API is invoked under.
2962
+ * `[in] arraybuffer`: The JavaScript `ArrayBuffer` to be detached.
2963
+
2964
+ Returns `napi_ok` if the API succeeded. If a non-detachable `ArrayBuffer` is
2965
+ passed in it returns `napi_detachable_arraybuffer_expected`.
2966
+
2967
+ Generally, an `ArrayBuffer` is non-detachable if it has been detached before.
2968
+ The engine may impose additional conditions on whether an `ArrayBuffer` is
2969
+ detachable. For example, V8 requires that the `ArrayBuffer` be external,
2970
+ that is, created with [`napi_create_external_arraybuffer`][].
2971
+
2972
+ This API represents the invocation of the `ArrayBuffer` detach operation as
2973
+ defined in [Section 24.1.1.3][] of the ECMAScript Language Specification.
2974
+
2949
2975
## Working with JavaScript Properties
2950
2976
2951
2977
N-API exposes a set of APIs to get and set properties on JavaScript
@@ -4889,6 +4915,7 @@ This API may only be called from the main thread.
4889
4915
[Section 22.1]: https://tc39.github.io/ecma262/#sec-array-objects
4890
4916
[Section 22.2]: https://tc39.github.io/ecma262/#sec-typedarray-objects
4891
4917
[Section 24.1]: https://tc39.github.io/ecma262/#sec-arraybuffer-objects
4918
+ [Section 24.1.1.3]: https://tc39.es/ecma262/#sec-detacharraybuffer
4892
4919
[Section 24.3]: https://tc39.github.io/ecma262/#sec-dataview-objects
4893
4920
[Section 25.4]: https://tc39.github.io/ecma262/#sec-promise-objects
4894
4921
[Section 6.1.4]: https://tc39.github.io/ecma262/#sec-ecmascript-language-types-string-type
0 commit comments