Kit
Functions

getBaseXResliceDecoder

getBaseXResliceDecoder(alphabet, bits): VariableSizeDecoder<string>

Returns a decoder for base-X encoded strings using bit re-slicing.

This decoder deserializes base-X encoded strings by re-slicing the bits of a byte array into custom-sized chunks and mapping them to a specified alphabet. This is typically used for encoding schemes where the alphabet's length is a power of 2, such as base-16 or base-64.

For more details, see getBaseXResliceCodec.

Parameters

ParameterTypeDescription
alphabetstringThe set of characters defining the base-X encoding.
bitsnumberThe number of bits per encoded chunk, typically log2(alphabet.length).

Returns

VariableSizeDecoder<string>

A VariableSizeDecoder<string> for decoding base-X strings using bit re-slicing.

Example

Decoding a base-X string using bit re-slicing.

const decoder = getBaseXResliceDecoder('elho', 2);
const value = decoder.decode(new Uint8Array([0x4a, 0xee])); // "hellolol"

See

getBaseXResliceCodec

On this page