Kit
Functions

getBytesEncoder

getBytesEncoder(): VariableSizeEncoder<Uint8Array<ArrayBufferLike> | ReadonlyUint8Array>

Returns an encoder for raw byte arrays.

This encoder writes byte arrays exactly as provided without modification.

The size of the encoded byte array is determined by the length of the input.

For more details, see getBytesCodec.

Returns

VariableSizeEncoder<Uint8Array<ArrayBufferLike> | ReadonlyUint8Array>

A VariableSizeEncoder<ReadonlyUint8Array | Uint8Array>.

Example

Encoding a byte array as-is.

const encoder = getBytesEncoder();
 
encoder.encode(new Uint8Array([1, 2, 3])); // 0x010203
encoder.encode(new Uint8Array([255, 0, 127])); // 0xff007f

See

getBytesCodec

On this page