DataView
A JavaScript object for reading and writing numbers of different sizes at any position in an ArrayBuffer, with the byte order chosen on every call.
In more detail
Methods such as getUint32(offset, littleEndian) take a Boolean saying whether to read little-endian. That makes DataView the right tool for binary protocol headers with mixed field sizes.
Related terms
- ArrayBuffer — A standard JavaScript object representing a block of raw binary memory, which you read and write through a typed array or DataView.
- endianness — The order in which the bytes of a multi-byte number are stored: most significant first (big-endian) or least significant first (little-endian).
- TypedArray — An array-like view, such as Uint8Array, that reads and writes numbers of one fixed type in an ArrayBuffer.
Taught in
- Binary Data Manipulation: TypedArrays & Endianness — Node.js Internals & Backend Services