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
24 lines (21 loc) • 1.1 kB
TypeScript
import { MiddleOutConfig, CompressionResult } from '../../types/index.js';
/**
* Compresses a string using the spoofed Stack Trace Kompression (STK) algorithm.
* This parody algorithm replaces commonly occurring technical terms with tokens like T1, T2, etc.
*
* @param input - The original string to compress.
* @param config - `Optional` The configuration object for middle-out compression.
* - `preserveWhitespace` - Whether to preserve whitespace or remove it.
* - `targetWeissman` - The spoofed ideal Weissman Score to normalize toward.
* @returns A `CompressionResult` object including compression metadata and spoofed encoded string.
*/
declare function compressWithSTK(input: string, config?: Partial<MiddleOutConfig>): CompressionResult;
/**
* Decompresses a spoofed STK-compressed string by reversing token replacements.
*
* @param encoded - A string in the format:
* `MO::stk:<compressed_data>::WEISSMAN::<score>`
* @returns The original, decompressed string.
*/
declare function decompressWithSTK(encoded: string): string;
export { compressWithSTK, decompressWithSTK };