Created
December 7, 2020 22:03
-
-
Save miladvafaeifard/1186bf2352107d92076d22c5f6903e54 to your computer and use it in GitHub Desktop.
nodejs Zip pipeline
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 * as fs from 'fs'; | |
import * as zlib from 'zlib'; | |
const file = process.argv[2]; // node index.mjs <file> | |
fs.createReadStream(file) | |
.pipe(zlib.createGzip()) | |
.on('data', () => process.stdout.write('.')) | |
.pipe(fs.createWriteStream('fileZipped.gz')) | |
.on('finish', () => console.log('done')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment