BinaryBuffer
Classes
- BinaryBuffer
Utility for reading/writing binary data Mostly useful for serialization/deserialization tasks
Constants
- MIN_GROWTH_STEP :
number
- MAX_SAFE_UINT_VAR :
number
2^31-1, values above this will be cropped incorrectly when bit-shifting
- DEFAULT_INITIAL_SIZE :
number
BinaryBuffer
Utility for reading/writing binary data Mostly useful for serialization/deserialization tasks
Kind: global class
- BinaryBuffer
- instance
- .endianness :
EndianType
|boolean
- .position :
number
- .capacity :
number
- .raw_bytes ⇒
Uint8Array
- .isBinaryBuffer :
boolean
- .fromArrayBuffer(data)
- .trim() ⇒
BinaryBuffer
- .setCapacity(capacity)
- .ensureCapacity(min_capacity)
- .readInt32() ⇒
number
- .readUint8() ⇒
number
- .readUint16() ⇒
number
- .readUint16LE() ⇒
number
- .readUint16BE() ⇒
number
- .readUint24() ⇒
number
- .readUint24LE() ⇒
number
- .readUint24BE() ⇒
number
- .readUint32() ⇒
number
- .readUint32LE() ⇒
number
- .readUint32BE() ⇒
number
- .readUint8Array(destination_offset, length, destination)
- .readUint16Array(destination_offset, length, destination)
- .readUint32Array(destination_offset, length, destination)
- .readInt8Array(destination_offset, length, destination)
- .readInt16Array(destination_offset, length, destination)
- .readInt32Array(destination_offset, length, destination)
- .readFloat32Array(destination_offset, length, destination)
- .readFloat64Array(destination_offset, length, destination)
- .writeFloat32Array(source_offset, length, source)
- .writeFloat32(value)
- .writeFloat64(value)
- .writeInt8(value)
- .writeInt16(value)
- .writeInt32(value)
- .writeUint8(value)
- .writeUint8Array(source, source_offset, length)
- .writeUint16(value)
- .writeUint16BE(value)
- .writeUint16LE(value)
- .writeUint16Array(source, source_offset, length)
- .writeUint24(value)
- .writeUint24BE(value)
- .writeUint24LE(value)
- .writeUintVar(value)
- .readUintVar() ⇒
number
- .writeUint32(value)
- .writeUint32BE(value)
- .writeUint32LE(value)
- .writeUint32Array(source, source_offset, length)
- .writeBytes(array, source_offset, length)
- .readBytes(destination, destination_offset, length)
- .writeUTF8String(string)
- .readUTF8String() ⇒
String
- .writeASCIIString(string)
- .readASCIICharacters(length, [null_terminated]) ⇒
string
- .endianness :
- static
- .fromEndianness(type) ⇒
BinaryBuffer
- .fromArrayBuffer(v) ⇒
BinaryBuffer
- .copyUTF8String(source, target) ⇒
string
- .copyUintVar(source, target) ⇒
number
- .copyUint8(source, target) ⇒
number
- .copyUint16(source, target) ⇒
number
- .copyUint32(source, target) ⇒
number
- .copyFloat32(source, target) ⇒
number
- .copyFloat64(source, target) ⇒
number
- .copyBytes(source, target, length)
- .fromEndianness(type) ⇒
- instance
binaryBuffer.endianness : EndianType
| boolean
Default is little-endian as most platforms operate in little-endian
Kind: instance property of BinaryBuffer
binaryBuffer.position : number
Kind: instance property of BinaryBuffer
binaryBuffer.capacity : number
Kind: instance property of BinaryBuffer
binaryBuffer.raw_bytes ⇒ Uint8Array
Access raw underlying bytes attached to the buffer
Kind: instance property of BinaryBuffer
binaryBuffer.isBinaryBuffer : boolean
Kind: instance property of BinaryBuffer
Read only: true
binaryBuffer.fromArrayBuffer(data)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
data | ArrayBuffer |
binaryBuffer.trim() ⇒ BinaryBuffer
Set capacity to contain data only up to current position
Kind: instance method of BinaryBuffer
binaryBuffer.setCapacity(capacity)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
capacity | number |
binaryBuffer.ensureCapacity(min_capacity)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
min_capacity | number |
binaryBuffer.readInt32() ⇒ number
Kind: instance method of BinaryBuffer
binaryBuffer.readUint8() ⇒ number
Kind: instance method of BinaryBuffer
binaryBuffer.readUint16() ⇒ number
Kind: instance method of BinaryBuffer
binaryBuffer.readUint16LE() ⇒ number
Kind: instance method of BinaryBuffer
binaryBuffer.readUint16BE() ⇒ number
Kind: instance method of BinaryBuffer
binaryBuffer.readUint24() ⇒ number
Kind: instance method of BinaryBuffer
binaryBuffer.readUint24LE() ⇒ number
Kind: instance method of BinaryBuffer
binaryBuffer.readUint24BE() ⇒ number
Kind: instance method of BinaryBuffer
binaryBuffer.readUint32() ⇒ number
Kind: instance method of BinaryBuffer
binaryBuffer.readUint32LE() ⇒ number
Kind: instance method of BinaryBuffer
binaryBuffer.readUint32BE() ⇒ number
Kind: instance method of BinaryBuffer
binaryBuffer.readUint8Array(destination_offset, length, destination)
Kind: instance method of BinaryBuffer
Param | Type | Description |
---|---|---|
destination_offset | number | starting index in the destination array |
length | number | number of elements to read |
destination | Uint8Array |
binaryBuffer.readUint16Array(destination_offset, length, destination)
Kind: instance method of BinaryBuffer
Param | Type | Description |
---|---|---|
destination_offset | number | starting index in the destination array |
length | number | number of elements to read |
destination | Uint16Array |
binaryBuffer.readUint32Array(destination_offset, length, destination)
Kind: instance method of BinaryBuffer
Param | Type | Description |
---|---|---|
destination_offset | number | starting index in the destination array |
length | number | number of elements to read |
destination | Uint32Array | Array.<number> | ArrayLike.<number> |
binaryBuffer.readInt8Array(destination_offset, length, destination)
Kind: instance method of BinaryBuffer
Param | Type | Description |
---|---|---|
destination_offset | number | starting index in the destination array |
length | number | number of elements to read |
destination | Int8Array |
binaryBuffer.readInt16Array(destination_offset, length, destination)
Kind: instance method of BinaryBuffer
Param | Type | Description |
---|---|---|
destination_offset | number | starting index in the destination array |
length | number | number of elements to read |
destination | Int16Array |
binaryBuffer.readInt32Array(destination_offset, length, destination)
Kind: instance method of BinaryBuffer
Param | Type | Description |
---|---|---|
destination_offset | number | starting index in the destination array |
length | number | number of elements to read |
destination | Int32Array |
binaryBuffer.readFloat32Array(destination_offset, length, destination)
Kind: instance method of BinaryBuffer
Param | Type | Description |
---|---|---|
destination_offset | number | starting index in the destination array |
length | number | number of elements to read |
destination | Float32Array | Array.<number> |
binaryBuffer.readFloat64Array(destination_offset, length, destination)
Kind: instance method of BinaryBuffer
Param | Type | Description |
---|---|---|
destination_offset | number | starting index in the destination array |
length | number | number of elements to read |
destination | Float64Array |
binaryBuffer.writeFloat32Array(source_offset, length, source)
Kind: instance method of BinaryBuffer
Param | Type | Description |
---|---|---|
source_offset | number | starting index in the source array |
length | number | number of elements to read |
source | Float32Array | Array.<number> |
binaryBuffer.writeFloat32(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeFloat64(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeInt8(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeInt16(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeInt32(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeUint8(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeUint8Array(source, source_offset, length)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
source | Uint8Array | Array.<number> |
source_offset | number |
length | number |
binaryBuffer.writeUint16(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeUint16BE(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeUint16LE(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeUint16Array(source, source_offset, length)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
source | Uint16Array | Array.<number> |
source_offset | number |
length | number |
binaryBuffer.writeUint24(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeUint24BE(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeUint24LE(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeUintVar(value)
Write Uint of variable length NOTE: uses 7-bit encoding with 1 bit used for carry-over flag
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.readUintVar() ⇒ number
Read Uint of variable length, a compliment to #writeUintVar
Kind: instance method of BinaryBuffer
binaryBuffer.writeUint32(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeUint32BE(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeUint32LE(value)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
value | number |
binaryBuffer.writeUint32Array(source, source_offset, length)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
source | Uint32Array | Array.<number> | ArrayLike.<number> |
source_offset | number |
length | number |
binaryBuffer.writeBytes(array, source_offset, length)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
array | Uint8Array | Uint8ClampedArray |
source_offset | number |
length | number |
binaryBuffer.readBytes(destination, destination_offset, length)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
destination | Uint8Array |
destination_offset | number |
length | number |
binaryBuffer.writeUTF8String(string)
Adapted from https://github.com/samthor/fast-text-encoding/blob/master/text.js
Kind: instance method of BinaryBuffer
Licence: Original license is Apache 2.0
Param | Type |
---|---|
string | String |
binaryBuffer.readUTF8String() ⇒ String
Adapted from https://github.com/samthor/fast-text-encoding/blob/master/text.js
Kind: instance method of BinaryBuffer
Licence: Original license is Apache 2.0
binaryBuffer.writeASCIIString(string)
Kind: instance method of BinaryBuffer
Param | Type |
---|---|
string | string |
binaryBuffer.readASCIICharacters(length, [null_terminated]) ⇒ string
Kind: instance method of BinaryBuffer
Param | Type | Default |
---|---|---|
length | number | |
[null_terminated] | boolean | false |
BinaryBuffer.fromEndianness(type) ⇒ BinaryBuffer
Kind: static method of BinaryBuffer
Param | Type |
---|---|
type | EndianType |
BinaryBuffer.fromArrayBuffer(v) ⇒ BinaryBuffer
Kind: static method of BinaryBuffer
Param | Type |
---|---|
v | ArrayBuffer |
BinaryBuffer.copyUTF8String(source, target) ⇒ string
Kind: static method of BinaryBuffer
Returns: string
- Copied value
Param | Type |
---|---|
source | BinaryBuffer |
target | BinaryBuffer |
BinaryBuffer.copyUintVar(source, target) ⇒ number
Kind: static method of BinaryBuffer
Returns: number
- Copied value
Param | Type |
---|---|
source | BinaryBuffer |
target | BinaryBuffer |
BinaryBuffer.copyUint8(source, target) ⇒ number
Kind: static method of BinaryBuffer
Returns: number
- Copied value
Param | Type |
---|---|
source | BinaryBuffer |
target | BinaryBuffer |
BinaryBuffer.copyUint16(source, target) ⇒ number
Kind: static method of BinaryBuffer
Returns: number
- Copied value
Param | Type |
---|---|
source | BinaryBuffer |
target | BinaryBuffer |
BinaryBuffer.copyUint32(source, target) ⇒ number
Kind: static method of BinaryBuffer
Returns: number
- Copied value
Param | Type |
---|---|
source | BinaryBuffer |
target | BinaryBuffer |
BinaryBuffer.copyFloat32(source, target) ⇒ number
Kind: static method of BinaryBuffer
Returns: number
- Copied value
Param | Type |
---|---|
source | BinaryBuffer |
target | BinaryBuffer |
BinaryBuffer.copyFloat64(source, target) ⇒ number
Kind: static method of BinaryBuffer
Returns: number
- Copied value
Param | Type |
---|---|
source | BinaryBuffer |
target | BinaryBuffer |
BinaryBuffer.copyBytes(source, target, length)
Kind: static method of BinaryBuffer
Param | Type |
---|---|
source | BinaryBuffer |
target | BinaryBuffer |
length | number |
MIN_GROWTH_STEP : number
Kind: global constant
MAX_SAFE_UINT_VAR : number
2^31-1, values above this will be cropped incorrectly when bit-shifting
Kind: global constant
DEFAULT_INITIAL_SIZE : number
Kind: global constant
Read only: true