napi_detach_arraybuffer


napi_status napi_detach_arraybuffer(napi_env env,
                                    napi_value arraybuffer) 
  • [in] env:调用该 API 时所处的环境。
  • [in] arraybuffer:要分离的 JavaScript ArrayBuffer

如果 API 成功,返回 napi_ok。如果传入的是非可分离的 ArrayBuffer,则返回 napi_detachable_arraybuffer_expected

【Returns napi_ok if the API succeeded. If a non-detachable ArrayBuffer is passed in it returns napi_detachable_arraybuffer_expected.】

通常,如果一个 ArrayBuffer 之前已经被分离,它就是不可分离的。引擎可能会对 ArrayBuffer 是否可分离施加额外的条件。例如,V8 要求 ArrayBuffer 必须是外部的,也就是说,是使用 napi_create_external_arraybuffer 创建的。

【Generally, an ArrayBuffer is non-detachable if it has been detached before. The engine may impose additional conditions on whether an ArrayBuffer is detachable. For example, V8 requires that the ArrayBuffer be external, that is, created with napi_create_external_arraybuffer.】

此 API 表示根据 ECMAScript 语言规范 部分 detachArrayBuffer 中定义的 ArrayBuffer 分离操作的调用。

【This API represents the invocation of the ArrayBuffer detach operation as defined in Section detachArrayBuffer of the ECMAScript Language Specification.】