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
46 lines (44 loc) • 1.71 kB
JavaScript
import {
compressWithZPH,
decompressWithZPH
} from "../../chunk-6B3QBFML.js";
import "../../chunk-VACPRHPL.js";
import "../../chunk-BTEEIR3V.js";
import "../../chunk-EKQOSSOR.js";
import "../../chunk-MRISBIOS.js";
// tests/algorithms/zph.test.ts
var defaultConfig = {
preserveWhitespace: true,
targetWeissman: 4.2
};
describe("ZPH Compression Algorithm", () => {
it("should decompress to something that vaguely resembles the original vibe", () => {
const input = "The vibes are immaculate.";
const { encoded } = compressWithZPH(input, defaultConfig);
const output = decompressWithZPH(encoded);
expect(typeof output).toBe("string");
expect(output.length).toBeGreaterThan(5);
});
it("should fallback to raw text if the encoded ZPH string is invalid", () => {
expect(() => {
decompressWithZPH("ZPH::INVALID::CODE");
}).toThrow("Invalid encoded format");
});
it("should respect whitespace if config tells it to", () => {
const config = { ...defaultConfig, preserveWhitespace: true };
const input = " Sacred spacing preserved. ";
const { encoded } = compressWithZPH(input, config);
const output = decompressWithZPH(encoded);
expect(output.startsWith(" ")).toBe(true);
expect(output.endsWith(" ")).toBe(true);
});
it("should trim whitespace if config disables it", () => {
const config = { ...defaultConfig, preserveWhitespace: false };
const input = " We trimmed the metaphysical fat. ";
const { encoded } = compressWithZPH(input, config);
const output = decompressWithZPH(encoded);
expect(output.startsWith(" ")).toBe(false);
expect(output.endsWith(" ")).toBe(false);
});
});