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.
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”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.
Methods
Section titled “Methods”decode()
Section titled “decode()”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.
Parameters
Section titled “Parameters”View
context
Section titled “context”Returns
Section titled “Returns”DecodeResult<T, W>
reset()?
Section titled “reset()?”
optionalreset():void
Defined in: packages/format-core/src/decoder.ts:31
Discard accumulated decode state ahead of a protocol mode switch.
Returns
Section titled “Returns”void