Skip to content

Decoder

Defined in: packages/format-core/src/decoder.ts:21

Decodes values from a view over accumulated input.

Decoders are injected into a driver (DecodeDriver, decodeAll, DecodeStream, or net/core’s FrameLink), never subclassed from one: they perform no I/O, hold no stream reference, and are testable against a plain view. They may be stateful — HPACK tables, WebSocket fragment reassembly, and RTMP chunk-header deltas all require it — in which case reset must restore the initial state.

T

The decoded value type.

View = Uint8Array

Backing representation of the accumulated input. Defaults to a contiguous Uint8Array; the parameter exists so a non-contiguous backing (see ByteCursor) or a text backing (string, see TextBuffer) can be used without a breaking signature change.

W = never

The best-effort warning type, riding on a decoded result.

decode(view, context): DecodeResult<T, W>

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

Attempt to decode one value from the front of view.

view is a window into the driver’s buffer and is invalidated as soon as this call returns. Copy anything retained in the returned value.

View

DecodeContext

DecodeResult<T, W>


optional reset(): void

Defined in: packages/format-core/src/decoder.ts:31

Discard accumulated decode state ahead of a protocol mode switch.

void