UNPKG

node-pkware

Version:

node.js implementation of StormLib's pkware compressor/de-compressor

47 lines (46 loc) 1.65 kB
import type { CompressionType, DictionarySize } from '../simple/types.js'; export declare class Implode { private inputBuffer; /** * Used for accessing the data within inputBuffer */ private inputBufferView; /** * Used for caching inputBuffer.byteLength as that getter is doing some uncached computation to measure the length of * inputBuffer */ private inputBufferSize; /** * The implode algorithm works by trimming off the beginning of inputBuffer byte by byte. Instead of actually * adjusting the inputBuffer every time a byte is handled we store the beginning of the unhandled section and use it * when indexing data that is being read. */ private inputBufferStartIndex; private readonly outputBuffer; private outputBufferView; private outputBufferSize; private dictionarySizeMask; private readonly distCodes; private readonly distBits; private outBits; private readonly nChBits; private readonly nChCodes; constructor(input: ArrayBufferLike, compressionType: CompressionType, dictionarySize: DictionarySize); getResult(): ArrayBuffer; private setupTables; private outputHeader; private processInput; private writeTerminationLiteral; /** * @returns false - non flushable * @returns true - flushable * @returns null - flushable, but there might be a better repetition */ private isRepetitionFlushable; /** * repetitions are at least 2 bytes long, * so the initial 2 bytes can be moved to the output as is */ private skipFirstTwoBytes; private outputBits; }