Skip to content

TextDecodeBuffer

Defined in: packages/format-core/src/text-decode-buffer.ts:17

A DecodeBuffer that accepts byte chunks and windows them as text.

The Chunk/View split exists for exactly this: a decoder written against string (NDJSON, CSV, INI) can be driven straight from a byte source without the caller inserting a TextDecoderStream and without each format hand-rolling its own driver wiring.

The TextDecoder is held across appends, so a multi-byte sequence split over a chunk boundary is reassembled rather than replaced.

new TextDecodeBuffer(maxSize, encoding?): TextDecodeBuffer

Defined in: packages/format-core/src/text-decode-buffer.ts:26

number

Maximum retained code-unit count; must be greater than zero.

string = "utf-8"

Label for the incoming bytes. Defaults to UTF-8.

TextDecodeBuffer

get buffered(): number

Defined in: packages/format-core/src/text-decode-buffer.ts:31

Unconsumed unit count currently held.

number

Unconsumed unit count currently held.

DecodeBuffer.buffered

append(chunk): void

Defined in: packages/format-core/src/text-decode-buffer.ts:35

Append chunk, growing or compacting the backing as needed.

Uint8Array

void

DecodeBuffer.append


clear(): void

Defined in: packages/format-core/src/text-decode-buffer.ts:57

Discard everything held.

void

DecodeBuffer.clear


consume(count): void

Defined in: packages/format-core/src/text-decode-buffer.ts:48

Drop count units from the front.

number

void

DecodeBuffer.consume


finish(): void

Defined in: packages/format-core/src/text-decode-buffer.ts:40

Flush any bytes the decoder is holding back, at end of input.

void

DecodeBuffer.finish


take(): Uint8Array

Defined in: packages/format-core/src/text-decode-buffer.ts:53

Residue is re-encoded as UTF-8, whatever the input encoding was.

Uint8Array

DecodeBuffer.take


view(): string

Defined in: packages/format-core/src/text-decode-buffer.ts:44

Window over the unconsumed units. Invalidated by the next append or consume; copy before retaining.

string

DecodeBuffer.view