Created
July 14, 2022 05:41
-
-
Save gagan-bansal/0ffd2d98e08cfdac6e4fc0eaeaccba15 to your computer and use it in GitHub Desktop.
Compress a file with gz using node.js zlib module.
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
const file = process.argv[2]; | |
const {promisify} = require('util'); | |
const zlib = require('zlib'); | |
const gzip = promisify(zlib.gzip); | |
(async () => { | |
const fs = require('fs'); | |
const data = fs.readFileSync(file, 'utf-8'); | |
const buf = await gzip(data) | |
fs.writeFileSync(`${file}.gz`, buf); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment