Kit
Interfaces

FixedSizeEncoder

An object that can encode a value of type TFrom into a fixed-size ReadonlyUint8Array.

See Encoder to learn more about creating and composing encoders.

Example

const encoder: FixedSizeEncoder<number, 4>;
const bytes = encoder.encode(42);
const size = encoder.fixedSize; // 4

See

Type Parameters

Type ParameterDefault typeDescription
TFrom-The type of the value to encode.
TSize extends numbernumberThe fixed size of the encoded value in bytes.

Properties

PropertyModifierTypeDescription
encodereadonly(value) => ReadonlyUint8ArrayEncode the provided value and return the encoded bytes directly.
fixedSizereadonlyTSizeThe fixed size of the encoded value in bytes.
writereadonly(value, bytes, offset) => numberWrites the encoded value into the provided byte array at the given offset. Returns the offset of the next byte after the encoded value.

On this page