A Codec encodes and (if supported) decodes data.

Codecs can be fused. For example fusing JSON and UTF8 produces an encoder that can convert Json objects directly to bytes, or can decode bytes directly to json objects.

Fused codecs generally attempt to optimize the operations and can be faster than executing each step of an encoding separately.

Codecs are still experimental and are subject to change without notice.

Implemented by

Properties

decoder Converter<T,S>
read-only

Returns the decoder of this, converting from T to S.

encoder Converter<S,T>
read-only

Returns the encoder from S to T.

inverted Codec<T,S>
read-only

Inverts this.

Constructors

Codec()
const

Methods

decode(T encoded) → S

encode(S input) → T

fuse(Codec<T> other) → Codec<S>

Fuses this with other.