UNPKG

middleout.js

Version:

A spoof compression library that pretends to revolutionize data compression using made-up algorithms — inspired by the legendary middle-out compression from Silicon Valley

28 lines (25 loc) 1.16 kB
import { MiddleOutConfig, CompressionResult } from '../../types/index.js'; /** * Compress a string using the Run-Length Encoding (RLE) algorithm. * * @param input - The raw string to compress. * @param config - `Optional` Compressions configuration incuding: * - `preserveWhitespace`: Whether to retain whitespace in compression * - `algorithm`: Must be `rle` to match alogrithm type. * - `aggressionLevel`: Ignored in RLE (included for compatibility). * - `targetWeissman`: Used for mocking ideal compression. * * @returns A `ComprehensionResult` with metadata and compressed data formatted as: `MO::rle:<encoded>::WEISSMAN::<score>` */ declare function compressWithRLE(input: string, config?: Partial<MiddleOutConfig>): CompressionResult; /** * Decompresses a string compressed using the RLE algorithm. * * @param encoded - A string in the format: * `MO::rle:<encoded_data>::WEISSMAN::<score>` * @returns The original, uncompressed string. * * @throws Will throw an error if the format is invalid or algorithm is not RLE. */ declare function decompressWithRLE(encoded: string): string; export { compressWithRLE, decompressWithRLE };