Skip to content

DecodeBuffer

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

Accumulates and windows the units a Decoder reads.

Chunk is the type appended (what arrives) and View is the type read back (what a decoder sees); they diverge for a non-contiguous backing — appending Uint8Array chunks while viewing them through a ByteCursor — so a single type parameter would be inexpressible here.

View

What view and take return.

Chunk = View

What append accepts. Defaults to View for the common contiguous case.

readonly buffered: number

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

Unconsumed unit count currently held.

append(chunk): void

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

Append chunk, growing or compacting the backing as needed.

Chunk

void


clear(): void

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

Discard everything held.

void


consume(count): void

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

Drop count units from the front.

number

void


optional finish(): void

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

Release anything the backing is holding back pending more input, called once when no further append will happen.

Only a converting backing needs this — a TextDecoder withholds the bytes of a sequence split across a chunk boundary, and at end of input they must become a replacement character rather than vanish.

void


take(): Chunk

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

Remove and return the unconsumed units, resetting the buffer.

Chunk


view(): View

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

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

View