Interface AdvancedLzwDecodeOptions

Advanced options, allowing for full control of the initial dictionary/decoding state.

import { Lzw } from '@4bitlabs/codecs';

const dictionary = [
Lzw.EOF_MARKER,
0x41, // A
0x42, // B
0x43, // C
0x44, // D
];

const bytes = Lzw.unpack(encodedBytes, { dictionary });

Longer codings can be encoded in the dictionary by using either an array of numbers of with a Uint8Array:

import { Lzw, EOF_MARKER } from '@4bitlabs/codecs';

const dictionary = [
Lzw.EOF_MARKER,
Uint8Array.of(0x47, 0x41, 0x54, 0x41), // GATA
Uint8Array.of(0x41, 0x54, 0x54, 0x41), // ATTA
Uint8Array.of(0x43, 0x47, 0x41, 0x54), // CGAT
Uint8Array.of(0x41, 0x43, 0x41, 0x47), // ACAG
];

const bytes = Lzw.unpack(encodedBytes, { dictionary });
interface AdvancedLzwDecodeOptions {
    dictionary: InitialDictionary;
    order?: "msb" | "lsb";
}

Properties

Properties

dictionary: InitialDictionary

Initialize the LZW dictionary.

order?: "msb" | "lsb"

Select the packing bit-ordering.

'lsb'