Encoder
Defined in: packages/format-core/src/encoder.ts:13
Encodes values to raw output units.
Encoders are injected the same way Decoders are: no I/O, no stream reference, testable in isolation. They may be stateful — HPACK tables and RTMP chunk-header deltas require it — in which case reset must restore the initial state.
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”Out
The value type to encode.
View = Uint8Array
Backing representation of the encoded output. Defaults to a
contiguous Uint8Array.
Methods
Section titled “Methods”encode()
Section titled “encode()”encode(
value):View| readonlyView[]
Defined in: packages/format-core/src/encoder.ts:21
Encode a value into one or more output chunks.
Returning an array defers concatenation to a vectored write, so a
length-prefixed protocol can emit [header, payload] without copying the
payload.
Parameters
Section titled “Parameters”Out
Returns
Section titled “Returns”View | readonly View[]
reset()?
Section titled “reset()?”
optionalreset():void
Defined in: packages/format-core/src/encoder.ts:24
Discard accumulated encode state ahead of a protocol mode switch.
Returns
Section titled “Returns”void