Skip to content

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.

Out

The value type to encode.

View = Uint8Array

Backing representation of the encoded output. Defaults to a contiguous Uint8Array.

encode(value): View | readonly View[]

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.

Out

View | readonly View[]


optional reset(): void

Defined in: packages/format-core/src/encoder.ts:24

Discard accumulated encode state ahead of a protocol mode switch.

void