CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/sync-fs/lib/compressed-json.ts
Views: 687
1
import { encode, decode } from "lz4";
2
3
export function toCompressedJSON(obj: any): Buffer {
4
return encode(Buffer.from(JSON.stringify(obj)));
5
}
6
7
export function fromCompressedJSON(compressedJSON: Buffer): any {
8
return JSON.parse(decode(compressedJSON).toString());
9
}
10
11