node_api_create_buffer_from_arraybuffer
napi_status NAPI_CDECL node_api_create_buffer_from_arraybuffer(napi_env env,
napi_value arraybuffer,
size_t byte_offset,
size_t byte_length,
napi_value* result)
-
[in] env
:调用 API 的环境。¥**
[in] env
**: The environment that the API is invoked under. -
[in] arraybuffer
:缓冲区将从哪个ArrayBuffer
创建。¥**
[in] arraybuffer
**: TheArrayBuffer
from which the buffer will be created. -
[in] byte_offset
:ArrayBuffer
中的字节偏移量,从该偏移量开始创建缓冲区。¥**
[in] byte_offset
**: The byte offset within theArrayBuffer
from which to start creating the buffer. -
[in] byte_length
:要从ArrayBuffer
创建的缓冲区的长度(以字节为单位)。¥**
[in] byte_length
**: The length in bytes of the buffer to be created from theArrayBuffer
. -
[out] result
:表示创建的 JavaScriptBuffer
对象的napi_value
。¥**
[out] result
**: Anapi_value
representing the created JavaScriptBuffer
object.
如果 API 成功,则返回 napi_ok
。
¥Returns napi_ok
if the API succeeded.
此 API 从现有的 ArrayBuffer
创建 JavaScript Buffer
对象。Buffer
对象是 Node.js 特定的类,它提供了一种在 JavaScript 中直接处理二进制数据的方法。
¥This API creates a JavaScript Buffer
object from an existing ArrayBuffer
.
The Buffer
object is a Node.js-specific class that provides a way to work with binary data directly in JavaScript.
字节范围 [byte_offset, byte_offset + byte_length)
必须在 ArrayBuffer
的范围内。如果 byte_offset + byte_length
超出 ArrayBuffer
的大小,则会引发 RangeError
异常。
¥The byte range [byte_offset, byte_offset + byte_length)
must be within the bounds of the ArrayBuffer
. If byte_offset + byte_length
exceeds the size of the ArrayBuffer
, a RangeError
exception is raised.