napi_create_dataview
napi_status napi_create_dataview(napi_env env,
size_t byte_length,
napi_value arraybuffer,
size_t byte_offset,
napi_value* result) [in] env:API 被调用时所处的环境。[in] length:DataView中的元素数量。[in] arraybuffer:ArrayBuffer或SharedArrayBuffer是DataView的基础。[in] byte_offset:在ArrayBuffer中开始投影DataView的字节偏移量。[out] result:一个表示 JavaScriptDataView的napi_value。
如果 API 成功,则返回 napi_ok。
🌐 Returns napi_ok if the API succeeded.
此 API 在现有的 ArrayBuffer 或 SharedArrayBuffer 上创建一个 JavaScript DataView 对象。DataView 对象提供了对底层数据缓冲区的类数组视图,但它允许 ArrayBuffer 或 SharedArrayBuffer 中的项目具有不同的大小和类型。
🌐 This API creates a JavaScript DataView object over an existing ArrayBuffer
or SharedArrayBuffer. DataView objects provide an array-like view over an
underlying data buffer, but one which allows items of different size and type in
the ArrayBuffer or SharedArrayBuffer.
要求 byte_length + byte_offset 小于或等于传入数组的字节大小。如果不满足,将抛出 RangeError 异常。
🌐 It is required that byte_length + byte_offset is less than or equal to the
size in bytes of the array passed in. If not, a RangeError exception is
raised.
JavaScript DataView 对象在 ECMAScript 语言规范的 部分 数据视图对象 中有描述。
🌐 JavaScript DataView objects are described in
Section DataView objects of the ECMAScript Language Specification.