Class: BinaryRecord

bre.BinaryRecord

BinaryRecord class is the base class for all binary record types.

This class cannot be directly instantiated. It needs to define subclasses with module:bre.defineObjectRecord or module:bre.defineArrayRecord.

Constructor

new BinaryRecord(buffer, byteOffset)

This class cannot be directly instantiated. It needs to define subclasses with bre.defineObjectRecord or bre.defineArrayRecord.

Parameters:
Name Type Description
buffer ArrayBuffer | DataView | TypedArray

The buffer to wrap.

byteOffset number | undefined

The start position to wrap.

Source:

Methods

(static) bitLength(record) → {number}

Gets length in bits of the given record.

const bits = bre.BinaryRecord.bitLength(record1)
console.log(bits)  // => 16
Parameters:
Name Type Description
record module:bre.BinaryRecord

The record to get.

Source:
Returns:

The length in bits of the record.

Type
number

(static) byteLength(record) → {number}

Gets length in bytes of the given record.

const bytes = bre.BinaryRecord.byteLength(record1)
console.log(bytes)  // => 2
Parameters:
Name Type Description
record module:bre.BinaryRecord

The record to get.

Source:
Returns:

The length in bytes of the record.

Type
number

(static) entries(record) → {IterableIterator.<Array.<any>>}

Gets the key-value pairs of the given record.

Object.entries does not work for records because the properties of records are getter/setter pairs in the prototype. Use this method instead.

const entries = bre.BinaryRecord.entries(record1)
console.log(entries)  // => [ ["a", 1], ["b", 10] ]
Parameters:
Name Type Description
record module:bre.BinaryRecord

The record to get.

Source:
Returns:

The key-value pairs of the record.

Type
IterableIterator.<Array.<any>>

(static) keys(record) → {IterableIterator.<string>}

Gets the keys of the given record.

Object.keys does not work for records because the properties of records are getter/setter pairs in the prototype. Use this method instead.

const keys = bre.BinaryRecord.keys(record1)
console.log(keys)  // => ["a", "b"]
Parameters:
Name Type Description
record module:bre.BinaryRecord

The record to get.

Source:
Returns:

The keys of the record.

Type
IterableIterator.<string>

(static) values(record) → {IterableIterator.<any>}

Gets the values of the given record.

Object.values does not work for records because the properties of records are getter/setter pairs in the prototype. Use this method instead.

const values = bre.BinaryRecord.values(record1)
console.log(values)  // => [1, 10]
Parameters:
Name Type Description
record module:bre.BinaryRecord

The record to get.

Source:
Returns:

The values of the record.

Type
IterableIterator.<any>