Home > @gglib/utils > BinaryReader

BinaryReader class

A wrapper around the ArrayBuffer and DataView. Simplifies reading binary data.

Signature:

export declare class BinaryReader 

Constructors

Constructor Modifiers Description
(constructor)(data) Creates a new instance of BinaryReader

Properties

Property Modifiers Type Description
canRead boolean Checks whether the readers position has not reached the end of the buffer
data ArrayBuffer The underlying data to read
littleEndian boolean Byte order to read. Default is true
position number The current position
view DataView The data view allowing to access the data

Methods

Method Modifiers Description
readBuffer(buffer, index, length)
readByte() Reads a single signed byte value
readByteArray(length) Reads a specified number of bytes as a byte array
readBytes(length, output) Reads a specified number of bytes
readDouble() Reads a single float64 value
readFloat() Reads a single float32 value
readInt() Reads a single int32 value
readLong() Reads a two uint32 values as low and high bits.
readShort() Reads a single signed short value
readString(length) Reads a string
readUByte() Reads a single unsigned byte value
readUInt() Reads a single uint32 value
readUShort() Reads a single unsigned short value
seekAbsolute(position) Jumps to the given position on the data array
seekRelative(position) Jumps to the given position (relative to the current postion) on the data array
slice(length) Returns a section of the buffer starting at current position
subarray(type, byteLength)
subarray(type, byteLength)
subarray(type, byteLength)
subarray(type, byteLength)
subarray(type, byteLength)
subarray(type, byteLength)
subarray(type, byteLength)
subarray(type, byteLength)