# DataView
用于使用原始二进制缓冲区的接口。
¥An interface for working with a raw binary buffer.
DataView API 与 JavaScript (MDN (opens new window)) 中的完全相同。
¥The DataView API is exactly as in JavaScript (MDN (opens new window)).
# 构造函数
¥Constructor
new DataView(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32)
在指定的缓冲区和区域上构造一个新的 DataView。
¥Constructs a new DataView on the specified buffer and region.
# 实例成员
¥Instance members
# 字段
¥Fields
readonly buffer: ArrayBuffer
后备缓冲区。
¥The backing buffer.
readonly byteLength: i32
该视图从其缓冲区开始的长度。
¥The length of this view from the start of its buffer.
readonly byteOffset: i32
该视图距其缓冲区开头的偏移量。
¥The offset of this view from the start of its buffer.
# 方法
¥Methods
function getFloat32(byteOffset: i32, littleEndian?: bool): f32
获取距视图开头指定偏移量处的 32 位浮点值。
¥Gets the 32-bit float value at the specified offset from the start of the view.
function getFloat64(byteOffset: i32, littleEndian?: bool): f64
获取距视图开头指定偏移量处的 64 位浮点值。
¥Gets the 64-bit float value at the specified offset from the start of the view.
function getInt8(byteOffset: i32): i8
获取距视图开头指定偏移量处的有符号 8 位整数值。
¥Gets the signed 8-bit integer value at the specified offset from the start of the view.
function getInt16(byteOffset: i32, littleEndian?: bool): i16
获取距视图开头指定偏移量处的有符号 16 位整数值。
¥Gets the signed 16-bit integer value at the specified offset from the start of the view.
function getInt32(byteOffset: i32, littleEndian?: bool): i32
获取距视图开头指定偏移量处的有符号 32 位整数值。
¥Gets the signed 32-bit integer value at the specified offset from the start of the view.
function getInt64(byteOffset: i32, littleEndian?: bool): i64
获取距视图开头指定偏移量处的有符号 64 位整数值。
¥Gets the signed 64-bit integer value at the specified offset from the start of the view.
function getUint8(byteOffset: i32, littleEndian?: bool): u8
获取距视图开头指定偏移量处的无符号 8 位整数值。
¥Gets the unsigned 8-bit integer value at the specified offset from the start of the view.
function getUint16(byteOffset: i32, littleEndian?: bool): u16
获取距视图开头指定偏移量处的无符号 16 位整数值。
¥Gets the unsigned 16-bit integer value at the specified offset from the start of the view.
function getUint32(byteOffset: i32, littleEndian?: bool): u32
获取距视图开头指定偏移量处的无符号 32 位整数值。
¥Gets the unsigned 32-bit integer value at the specified offset from the start of the view.
function getUint64(byteOffset: i32, littleEndian?: bool): u64
获取距视图开头指定偏移量处的无符号 64 位整数值。
¥Gets the unsigned 64-bit integer value at the specified offset from the start of the view.
function setFloat32(byteOffset: i32, value: f32, littleEndian?: bool): void
在距视图开头的指定偏移处设置 32 位浮点值。
¥Sets the 32-bit float value at the specified offset from the start of the view.
function setFloat64(byteOffset: i32, value: f64, littleEndian?: bool): void
在距视图开头的指定偏移处设置 64 位浮点值。
¥Sets the 64-bit float value at the specified offset from the start of the view.
function setInt8(byteOffset: i32, value: i8): void
在距视图开头的指定偏移处设置带符号的 8 位整数值。
¥Sets the signed 8-bit integer value at the specified offset from the start of the view.
function setInt16(byteOffset: i32, value: i16, littleEndian?: bool): void
在距视图开头的指定偏移处设置有符号 16 位整数值。
¥Sets the signed 16-bit integer value at the specified offset from the start of the view.
function setInt32(byteOffset: i32, value: i32, littleEndian?: bool): void
在距视图开头的指定偏移处设置有符号 32 位整数值。
¥Sets the signed 32-bit integer value at the specified offset from the start of the view.
function setInt64(byteOffset: i32, value: i64, littleEndian?: bool): void
在距视图开头的指定偏移处设置有符号 64 位整数值。
¥Sets the signed 64-bit integer value at the specified offset from the start of the view.
function setUint8(byteOffset: i32, value: u8, littleEndian?: bool): void
在距视图开头的指定偏移处设置无符号 8 位整数值。
¥Sets the unsigned 8-bit integer value at the specified offset from the start of the view.
function setUint16(byteOffset: i32, value: u16, littleEndian?: bool): void
在距视图开头的指定偏移处设置无符号 16 位整数值。
¥Sets the unsigned 16-bit integer value at the specified offset from the start of the view.
function setUint32(byteOffset: i32, value: u32, littleEndian?: bool): void
在距视图开头的指定偏移处设置无符号 32 位整数值。
¥Sets the unsigned 32-bit integer value at the specified offset from the start of the view.
function setUint64(byteOffset: i32, value: u64, littleEndian?: bool): void
在距视图开头的指定偏移处设置无符号 64 位整数值。
¥Sets the unsigned 64-bit integer value at the specified offset from the start of the view.
function toString(): string
返回此对象的字符串表示形式。
¥Returns a string representation of this object.
字节顺序默认为 littleEndian = false
。
¥Endianness defaults to littleEndian = false
.