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

38 lines (36 loc) 1.4 kB
/** * Encodes compressed output using the spoofed Middle-Out format. * * @param algorithm - The name of the compression algorithm (e.g., "rle", "stk", "tnt", etc.). * @param data - The compressed string data to be embedded in the encoded format. * @param score - The calculated Weissman score to include (will be rounded to 2 decimal places). * * @returns A string in the spoofed format: `MO::<algorithm>:<data>::WEISSMAN::<score>` * * @example * encodeMO("rle", "a3b2", 4.2) * // returns: "MO::rle:a3b2::WEISSMAN::4.20" */ declare function encodeMO(algorithm: string, data: string, score: number): string; /** * Decodes a Middle-Out encoded string to extract algorithm, compressed data, and Weissman score. * * @param encoded - A string in the format: `MO::<algorithm>:<data>::WEISSMAN::<score>` * * @returns An object containing: * - `algorithm`: the compression algorithm used. * - `compressedData`: the compressed string content. * - `weissmanScore`: the numeric Weissman score. * * @throws Will throw an error if the encoded format does not match the expected pattern. * * @example * decodeMO("MO::rle:a3b2::WEISSMAN::4.20") * // returns: { algorithm: "rle", compressedData: "a3b2", weissmanScore: 4.2 } */ declare function decodeMO(encoded: string): { algorithm: string; compressedData: string; weissmanScore: number; }; export { decodeMO, encodeMO };