Typed Array - Khronos
Typed Array - Khronos is an HTML5 feature that allows you to access binary data in JavaScript. It is designed to effectively handle complex binary data of WebGL. It provides better performance than the WebGL - Khronos API (in mobile or wearable applications), while manipulating binary data and handling the data of other HTML APIs.
A typed array is capable of handling binary data in different sources:
- Network protocol
- Binary file formats
- Raw graphic buffers
Additionally, a typed array can be used to manage in-memory binary data of byte layouts, and assist in efficiently manipulating raw data for complex and powerful Web applications, such as audio and video operation, Web sockets, and the File API operations.
The main features of the Typed Array - Khronos API include:
- Creating an array buffer
An ArrayBuffer is a fixed-length binary data buffer, and a reference to the used raw binary data in the data format. It does not interact with the data directly, but creates a new instance of the ArrayBufferView object. The instance presents the buffer in a certain format, and can read and write the buffer content.
- Using typed array views
A TypedArrayView can be used to establish a detailed data structure. To create a typed array view, you must create an array buffer and the view that points to the array buffer.
The array buffer view shares information between views of all types, and has the following properties:
- Typed array view types
In the typed array view types, an array buffer view is used while manipulating and indexing binary data and returning the value of a general number. The specification of the respective array buffer length is fixed, and forms the basis for typed array view types.
The following table describes the typed array view types.
Table: Typed array view types Type Size1 Description Equivalent C type Int8Array 1 8-bit 2's complement signed integer signed char Uint8Array 1 8-bit unsigned integer unsigned char Uint8ClampedArray2 1 8-bit unsigned integer (clamped) unsigned char Int16Array 2 16-bit 2's complement signed integer short Uint16Array 2 16-bit unsigned integer unsigned short Int32Array 4 32-bit 2's complement signed integer int Uint32Array 4 32-bit unsigned integer unsigned int Float32Array 4 32-bit IEEE floating point float Float64Array 8 64-bit IEEE floating point double 1 The size unit is bytes, and it corresponds to the BYTES_PER_ELEMENT constant for the given type.
2 The Uint8ClampedArray is a special view, and it replaces the CanvasPixelArray.
Note There are no restrictions related to sorting the typed array view types. - DataView view types
The DataView view types are used to handle heterogeneous data with a defined byte order, displaying chunks of data read from a disk or the network. Since the view types import the API with the same array, the DataView objects set the API to randomly read and write data from the byte offset.
- Typed array view types
- Using typed arrays
You can deliver binary data effectively in other HTML5 APIs that employ a typed array, such as: