Add DataView to standard library (#316)

This commit is contained in:
Linus Unnebäck
2018-11-12 06:41:04 +00:00
committed by Daniel Wirtz
parent 6f3209e6c6
commit 3f9758f35a
5 changed files with 5042 additions and 0 deletions

View File

@ -243,6 +243,50 @@ declare class ArrayBuffer {
slice(begin?: i32, end?: i32): ArrayBuffer;
}
/** The `DataView` view provides a low-level interface for reading and writing multiple number types in a binary `ArrayBuffer`, without having to care about the platform's endianness. */
declare class DataView {
/** The `buffer` accessor property represents the `ArrayBuffer` or `SharedArrayBuffer` referenced by the `DataView` at construction time. */
readonly buffer: ArrayBuffer;
/** The `byteLength` accessor property represents the length (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */
readonly byteLength: i32;
/** The `byteOffset` accessor property represents the offset (in bytes) of this view from the start of its `ArrayBuffer` or `SharedArrayBuffer`. */
readonly byteOffset: i32;
/** Constructs a new `DataView` with the given properties */
constructor(buffer: ArrayBuffer, byteOffset?: i32, byteLength?: i32);
/** The `getFloat32()` method gets a signed 32-bit float (float) at the specified byte offset from the start of the `DataView`. */
getFloat32(byteOffset: i32, littleEndian?: boolean): f32
/** The `getFloat64()` method gets a signed 64-bit float (double) at the specified byte offset from the start of the `DataView`. */
getFloat64(byteOffset: i32, littleEndian?: boolean): f64
/** The `getInt8()` method gets a signed 8-bit integer (byte) at the specified byte offset from the start of the `DataView`. */
getInt8(byteOffset: i32): i8
/** The `getInt16()` method gets a signed 16-bit integer (short) at the specified byte offset from the start of the `DataView`. */
getInt16(byteOffset: i32, littleEndian?: boolean): i16
/** The `getInt32()` method gets a signed 32-bit integer (long) at the specified byte offset from the start of the `DataView`. */
getInt32(byteOffset: i32, littleEndian?: boolean): i32
/** The `getUint8()` method gets an unsigned 8-bit integer (unsigned byte) at the specified byte offset from the start of the `DataView`. */
getUint8(byteOffset: i32): u8
/** The `getUint16()` method gets an unsigned 16-bit integer (unsigned short) at the specified byte offset from the start of the `DataView`. */
getUint16(byteOffset: i32, littleEndian?: boolean): u16
/** The `getUint32()` method gets an unsigned 32-bit integer (unsigned long) at the specified byte offset from the start of the `DataView`. */
getUint32(byteOffset: i32, littleEndian?: boolean): u32
/** The `setFloat32()` method stores a signed 32-bit float (float) value at the specified byte offset from the start of the `DataView`. */
setFloat32(byteOffset: i32, value: f32, littleEndian?: boolean): void
/** The `setFloat64()` method stores a signed 64-bit float (double) value at the specified byte offset from the start of the `DataView`. */
setFloat64(byteOffset: i32, value: f64, littleEndian?: boolean): void
/** The `setInt8()` method stores a signed 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */
setInt8(byteOffset: i32, value: i8): void
/** The `setInt16()` method stores a signed 16-bit integer (short) value at the specified byte offset from the start of the `DataView`. */
setInt16(byteOffset: i32, value: i16, littleEndian?: boolean): void
/** The `setInt32()` method stores a signed 32-bit integer (long) value at the specified byte offset from the start of the `DataView`. */
setInt32(byteOffset: i32, value: i32, littleEndian?: boolean): void
/** The `setUint8()` method stores an unsigned 8-bit integer (byte) value at the specified byte offset from the start of the `DataView`. */
setUint8(byteOffset: i32, value: u8): void
/** The `setUint16()` method stores an unsigned 16-bit integer (unsigned short) value at the specified byte offset from the start of the `DataView`. */
setUint16(byteOffset: i32, value: u16, littleEndian?: boolean): void
/** The `setUint32()` method stores an unsigned 32-bit integer (unsigned long) value at the specified byte offset from the start of the `DataView`. */
setUint32(byteOffset: i32, value: u32, littleEndian?: boolean): void
}
declare class Array<T> {
[key: number]: T;
length: i32;