Skip to main content

Class: BinaryDecoder

A class that provides methods for decoding binary data.

Constructors

new BinaryDecoder()

new BinaryDecoder(writer: BufferReader): BinaryDecoder

Creates a new binary decoder.

Parameters

ParameterTypeDescription

writer

BufferReader

The buffer reader

Returns

BinaryDecoder

Defined in

binary-decoder.ts:18

Methods

fromArrayBuffer()

static fromArrayBuffer(buffer: ArrayBuffer): BinaryDecoder

Creates a new binary decoder from an ArrayBuffer.

Parameters

ParameterTypeDescription

buffer

ArrayBuffer

The ArrayBuffer to decode

Returns

BinaryDecoder

The new binary decoder instance

Defined in

binary-decoder.ts:27


decode()

decode<T>(schema: T): InferBaseType<T>

Decodes a value from the buffer.

Type Parameters

Type Parameter

T extends BaseType<unknown>

Parameters

ParameterTypeDescription

schema

T

The schema of the value to decode

Returns

InferBaseType<T>

The decoded value

Throws

RangeError if the byte size of the readable schema is larger than the buffer size

Defined in

binary-decoder.ts:37

Properties

PropertyModifierTypeDescriptionDefined in
readerreadonlyBufferReaderThe buffer reader.binary-decoder.ts:12