Created
February 9, 2025 00:21
-
-
Save JSmith01/1a39028e289113616d529b89e928d5e8 to your computer and use it in GitHub Desktop.
Two one-liners for browsers, one for packing data into .gz format, the other to unpack. Requires Compression Streams API.
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
// works for modern browsers supporting Compression Streams API - https://developer.mozilla.org/en-US/docs/Web/API/Compression_Streams_API | |
const unpackGzip = buffer => new Response(new Blob([buffer]).stream().pipeThrough(new DecompressionStream('gzip'))).arrayBuffer(); | |
const packGzip = buffer => new Response(new Blob([buffer]).stream().pipeThrough(new CompressionStream('gzip'))).arrayBuffer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment