Created
March 6, 2023 00:41
-
-
Save kenzauros/5707b1321aa006c3752aa7a7cae5b39b to your computer and use it in GitHub Desktop.
gzip compress/decompress (base64 encoded)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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