Files
pangolin/server/lib/textCompression.ts
T
2026-08-26 11:28:14 -04:00

16 lines
477 B
TypeScript

import { gzipSync, gunzipSync } from "zlib";
/**
* Gzip a string and return it as base64 so it can be stored in a TEXT column.
*/
export function compressText(value: string): string {
return gzipSync(Buffer.from(value, "utf8")).toString("base64");
}
/**
* Reverse of compressText - base64-decode and gunzip back to the original string.
*/
export function decompressText(value: string): string {
return gunzipSync(Buffer.from(value, "base64")).toString("utf8");
}