mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-27 06:24:56 +02:00
Handle compression of ai session logs
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
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");
|
||||
}
|
||||
Reference in New Issue
Block a user