Skip to main content

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.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

ParamType
dataArrayBuffer

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

ParamType
capacitynumber

binaryBuffer.ensureCapacity(min_capacity)

Kind: instance method of BinaryBuffer

ParamType
min_capacitynumber

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

ParamTypeDescription
destination_offsetnumberstarting index in the destination array
lengthnumbernumber of elements to read
destinationUint8Array

binaryBuffer.readUint16Array(destination_offset, length, destination)

Kind: instance method of BinaryBuffer

ParamTypeDescription
destination_offsetnumberstarting index in the destination array
lengthnumbernumber of elements to read
destinationUint16Array

binaryBuffer.readUint32Array(destination_offset, length, destination)

Kind: instance method of BinaryBuffer

ParamTypeDescription
destination_offsetnumberstarting index in the destination array
lengthnumbernumber of elements to read
destinationUint32Array | Array.<number> | ArrayLike.<number>

binaryBuffer.readInt8Array(destination_offset, length, destination)

Kind: instance method of BinaryBuffer

ParamTypeDescription
destination_offsetnumberstarting index in the destination array
lengthnumbernumber of elements to read
destinationInt8Array

binaryBuffer.readInt16Array(destination_offset, length, destination)

Kind: instance method of BinaryBuffer

ParamTypeDescription
destination_offsetnumberstarting index in the destination array
lengthnumbernumber of elements to read
destinationInt16Array

binaryBuffer.readInt32Array(destination_offset, length, destination)

Kind: instance method of BinaryBuffer

ParamTypeDescription
destination_offsetnumberstarting index in the destination array
lengthnumbernumber of elements to read
destinationInt32Array

binaryBuffer.readFloat32Array(destination_offset, length, destination)

Kind: instance method of BinaryBuffer

ParamTypeDescription
destination_offsetnumberstarting index in the destination array
lengthnumbernumber of elements to read
destinationFloat32Array | Array.<number>

binaryBuffer.readFloat64Array(destination_offset, length, destination)

Kind: instance method of BinaryBuffer

ParamTypeDescription
destination_offsetnumberstarting index in the destination array
lengthnumbernumber of elements to read
destinationFloat64Array

binaryBuffer.writeFloat32Array(source_offset, length, source)

Kind: instance method of BinaryBuffer

ParamTypeDescription
source_offsetnumberstarting index in the source array
lengthnumbernumber of elements to read
sourceFloat32Array | Array.<number>

binaryBuffer.writeFloat32(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeFloat64(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeInt8(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeInt16(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeInt32(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeUint8(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeUint8Array(source, source_offset, length)

Kind: instance method of BinaryBuffer

ParamType
sourceUint8Array | Array.<number>
source_offsetnumber
lengthnumber

binaryBuffer.writeUint16(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeUint16BE(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeUint16LE(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeUint16Array(source, source_offset, length)

Kind: instance method of BinaryBuffer

ParamType
sourceUint16Array | Array.<number>
source_offsetnumber
lengthnumber

binaryBuffer.writeUint24(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeUint24BE(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeUint24LE(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

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

ParamType
valuenumber

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

ParamType
valuenumber

binaryBuffer.writeUint32BE(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeUint32LE(value)

Kind: instance method of BinaryBuffer

ParamType
valuenumber

binaryBuffer.writeUint32Array(source, source_offset, length)

Kind: instance method of BinaryBuffer

ParamType
sourceUint32Array | Array.<number> | ArrayLike.<number>
source_offsetnumber
lengthnumber

binaryBuffer.writeBytes(array, source_offset, length)

Kind: instance method of BinaryBuffer

ParamType
arrayUint8Array | Uint8ClampedArray
source_offsetnumber
lengthnumber

binaryBuffer.readBytes(destination, destination_offset, length)

Kind: instance method of BinaryBuffer

ParamType
destinationUint8Array
destination_offsetnumber
lengthnumber

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

ParamType
stringString

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

ParamType
stringstring

binaryBuffer.readASCIICharacters(length, [null_terminated]) ⇒ string

Kind: instance method of BinaryBuffer

ParamTypeDefault
lengthnumber
[null_terminated]booleanfalse

BinaryBuffer.fromEndianness(type) ⇒ BinaryBuffer

Kind: static method of BinaryBuffer

ParamType
typeEndianType

BinaryBuffer.fromArrayBuffer(v) ⇒ BinaryBuffer

Kind: static method of BinaryBuffer

ParamType
vArrayBuffer

BinaryBuffer.copyUTF8String(source, target) ⇒ string

Kind: static method of BinaryBuffer
Returns: string - Copied value

ParamType
sourceBinaryBuffer
targetBinaryBuffer

BinaryBuffer.copyUintVar(source, target) ⇒ number

Kind: static method of BinaryBuffer
Returns: number - Copied value

ParamType
sourceBinaryBuffer
targetBinaryBuffer

BinaryBuffer.copyUint8(source, target) ⇒ number

Kind: static method of BinaryBuffer
Returns: number - Copied value

ParamType
sourceBinaryBuffer
targetBinaryBuffer

BinaryBuffer.copyUint16(source, target) ⇒ number

Kind: static method of BinaryBuffer
Returns: number - Copied value

ParamType
sourceBinaryBuffer
targetBinaryBuffer

BinaryBuffer.copyUint32(source, target) ⇒ number

Kind: static method of BinaryBuffer
Returns: number - Copied value

ParamType
sourceBinaryBuffer
targetBinaryBuffer

BinaryBuffer.copyFloat32(source, target) ⇒ number

Kind: static method of BinaryBuffer
Returns: number - Copied value

ParamType
sourceBinaryBuffer
targetBinaryBuffer

BinaryBuffer.copyFloat64(source, target) ⇒ number

Kind: static method of BinaryBuffer
Returns: number - Copied value

ParamType
sourceBinaryBuffer
targetBinaryBuffer

BinaryBuffer.copyBytes(source, target, length)

Kind: static method of BinaryBuffer

ParamType
sourceBinaryBuffer
targetBinaryBuffer
lengthnumber

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