Kit
Functions

getBitArrayDecoder

getBitArrayDecoder<TSize>(size, config?): FixedSizeDecoder<boolean[], TSize>

Returns a decoder that unpacks bits into an array of booleans.

This decoder converts a compact bit representation back into a list of boolean values. Each byte is expanded into 8 booleans.

The backward config option determines whether the bits are read in MSB-first (false) or LSB-first (true).

For more details, see getBitArrayCodec.

Type Parameters

Type ParameterDescription
TSize extends numberThe number of bytes used to store the bit array.

Parameters

ParameterTypeDescription
sizeTSizeThe number of bytes allocated for the bit array (must be sufficient for the expected boolean count).
config?boolean | BitArrayCodecConfigConfiguration options for decoding the bit array.

Returns

FixedSizeDecoder<boolean[], TSize>

A FixedSizeDecoder<boolean[], TSize> for decoding bit arrays.

Example

Decoding a bit array.

const decoder = getBitArrayDecoder(1);
 
decoder.decode(new Uint8Array([0xa0]));
// [true, false, true, false, false, false, false, false]

See

getBitArrayCodec

On this page