Skip to content

Instantly share code, notes, and snippets.

@kenzauros
Created March 6, 2023 00:41
Show Gist options
  • Save kenzauros/5707b1321aa006c3752aa7a7cae5b39b to your computer and use it in GitHub Desktop.
Save kenzauros/5707b1321aa006c3752aa7a7cae5b39b to your computer and use it in GitHub Desktop.
gzip compress/decompress (base64 encoded)
import { Buffer } from "buffer";
import zlib from "zlib";
export function gzip(str: string) {
return zlib.gzipSync(encodeURIComponent(str)).toString("base64");
}
export function unzip(value: string) {
return decodeURIComponent(zlib.unzipSync(Buffer.from(value, "base64")).toString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment