napi_get_typedarray_info


napi_status napi_get_typedarray_info(napi_env env,
                                     napi_value typedarray,
                                     napi_typedarray_type* type,
                                     size_t* length,
                                     void** data,
                                     napi_value* arraybuffer,
                                     size_t* byte_offset) 
  • [in] env:调用该 API 时所处的环境。
  • [in] typedarray:表示要查询其属性的 TypedArraynapi_value
  • [out] typeTypedArray 中元素的标量数据类型。
  • [out] lengthTypedArray 中的元素数量。
  • [out] 数据TypedArray 底层的数据缓冲区,已根据 byte_offset 值进行调整,以便指向 TypedArray 中的第一个元素。如果数组的长度为 0,则此值可能为 NULL 或其他任意指针值。
  • [out] arraybufferTypedArray 所依赖的 ArrayBuffer
  • [out] byte_offset:底层本地数组中数组第一个元素所在的字节偏移。data 参数的值已经被调整,使得 data 指向数组中的第一个元素。因此,本地数组的第一个字节位置为 data - byte_offset

如果 API 成功,则返回 napi_ok

【Returns napi_ok if the API succeeded.】

此 API 返回类型化数组的各种属性。

【This API returns various properties of a typed array.】

如果不需要该属性,任何输出参数都可以为 NULL

【Any of the out parameters may be NULL if that property is unneeded.】

警告: 使用此 API 时请小心,因为底层数据缓冲区由虚拟机管理。

Warning: Use caution while using this API since the underlying data buffer is managed by the VM.】