Skip to content

ByteBuilder

Defined in: packages/core/src/buffer/stream/byte-builder.ts:13

Accumulates byte chunks and concatenates them into one Uint8Array on demand — an incremental writer for any binary format built up byte-by-byte or chunk-by-chunk (PEM framing, SSH wire messages, PGP packets, ASN.1 codecs, …).

Every write/writeByte call is O(1) (a chunk is only ever appended, never copied or re-allocated); the cost of concatenation is paid exactly once, in toBytes().

new ByteBuilder(): ByteBuilder

ByteBuilder

get byteLength(): number

Defined in: packages/core/src/buffer/stream/byte-builder.ts:18

Total bytes written so far.

number

toBytes(): Uint8Array

Defined in: packages/core/src/buffer/stream/byte-builder.ts:39

Concatenates every chunk written so far into one Uint8Array.

Uint8Array


write(bytes): void

Defined in: packages/core/src/buffer/stream/byte-builder.ts:29

Appends bytes verbatim. A zero-length input is a no-op.

Uint8Array

void


writeByte(byte): void

Defined in: packages/core/src/buffer/stream/byte-builder.ts:23

Appends a single byte, taken mod 256.

number

void