Skip to main content

Class: ByteStream

Base class for reading and writing binary data.

Extended by​

Accessors​

buffer​

Get Signature​

get buffer(): ArrayBufferLike

Returns the underlying buffer

Returns​

ArrayBufferLike

Defined in​

byte-stream.ts:109


view​

Get Signature​

get view(): DataView

Returns the underlying DataView instance

Returns​

DataView

Defined in​

byte-stream.ts:116


position​

Get Signature​

get position(): number

Returns the current offset in the buffer in bytes.

Returns​

number

Defined in​

byte-stream.ts:123

Constructors​

new ByteStream()​

new ByteStream(buffer: ArrayBufferLike): ByteStream

Creates a new buffer view.

Parameters​

ParameterTypeDescription

buffer

ArrayBufferLike

The ArrayBuffer/SharedArrayBuffer to read/write data from/to

Returns​

ByteStream

Defined in​

byte-stream.ts:50

new ByteStream()​

new ByteStream(typedArray: TypedArray): ByteStream

Creates a new buffer view.

Parameters​

ParameterTypeDescription

typedArray

TypedArray

The TypedArray to read/write data from/to

Returns​

ByteStream

Defined in​

byte-stream.ts:56

Methods​

subarray()​

subarray(start: number, end: number): Uint8Array

Returns a subarray of the buffer.

Parameters​

ParameterTypeDescription

start

number

The start offset in bytes

end

number

The end offset in bytes

Returns​

Uint8Array

The subarray

Remarks​

The returned Uint8Array shares the same memory as the buffer.

Defined in​

byte-stream.ts:80


seek()​

seek(position: number): void

Seeks to a specific offset in the buffer.

Parameters​

ParameterTypeDescription

position

number

The offset to seek to

Returns​

void

Throws​

RangeError if the position is out of bounds

Defined in​

byte-stream.ts:89


skip()​

skip(offset: number): void

Skips a number of bytes in the buffer.

Parameters​

ParameterTypeDescription

offset

number

The number of bytes to skip

Returns​

void

Throws​

RangeError if the offset is out of bounds

Defined in​

byte-stream.ts:102

Properties​

PropertyModifierTypeDescriptionDefined in
_bufferprotectedArrayBufferLikeThe underlying buffer.byte-stream.ts:29
_viewprotectedDataViewThe DataView instance to read data from the buffer.byte-stream.ts:34
_u8protectedUint8ArrayThe Uint8Array instance to read data from the buffer.byte-stream.ts:39
_offsetprotectednumberThe current offset in the buffer in bytes.byte-stream.ts:44