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] env
: The environment that the API is invoked under. -
[in] typedarray
:napi_value
表示要查询其属性的TypedArray
。¥
[in] typedarray
:napi_value
representing theTypedArray
whose properties to query. -
[out] type
:TypedArray
中元素的标量数据类型。¥
[out] type
: Scalar datatype of the elements within theTypedArray
. -
[out] length
:TypedArray
中的元素数。¥
[out] length
: The number of elements in theTypedArray
. -
[out] data
:TypedArray
底层的数据缓冲区由byte_offset
值调整,使其指向TypedArray
中的第一个元素。如果数组的长度是0
,这可能是NULL
或任何其他指针值。¥
[out] data
: The data buffer underlying theTypedArray
adjusted by thebyte_offset
value so that it points to the first element in theTypedArray
. If the length of the array is0
, this may beNULL
or any other pointer value. -
[out] arraybuffer
:TypedArray
下的ArrayBuffer
。¥
[out] arraybuffer
: TheArrayBuffer
underlying theTypedArray
. -
[out] byte_offset
:数组的第一个元素所在的基础原生数组中的字节偏移量。data 参数的值已经过调整,因此 data 指向数组中的第一个元素。因此,原生数组的第一个字节将位于data - byte_offset
。¥
[out] byte_offset
: The byte offset within the underlying native array at which the first element of the arrays is located. The value for the data parameter has already been adjusted so that data points to the first element in the array. Therefore, the first byte of the native array would be atdata - 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 时要小心,因为底层数据缓冲区由 VM 管理。
¥Warning: Use caution while using this API since the underlying data buffer is managed by the VM.