Skip to content

TextBuffer

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

A DecodeBuffer over accumulated text.

Byte→text conversion happens upstream (a TextDecoderStream or CharsetDecodeStream); this only concatenates and windows the resulting strings, so consumed counts UTF-16 code units, matching String indexing.

new TextBuffer(maxSize): TextBuffer

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

Construct a buffer with a maximum retained code-unit count.

The ceiling is mandatory for the same reason ByteAccumulator’s is: a decoder that never reaches a verdict would otherwise let a peer grow this without bound.

number

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

TextBuffer

get buffered(): number

Defined in: packages/format-core/src/text-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-buffer.ts:39

string

void

If the retained count would exceed the configured ceiling.

DecodeBuffer.append


clear(): void

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

Discard everything held.

void

DecodeBuffer.clear


consume(count): void

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

Drop count units from the front.

number

void

DecodeBuffer.consume


take(): string

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

Remove and return the unconsumed units, resetting the buffer.

string

DecodeBuffer.take


view(): string

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

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

string

DecodeBuffer.view