Skip to content

Instantly share code, notes, and snippets.

@miladvafaeifard
Created December 7, 2020 22:03
Show Gist options
  • Save miladvafaeifard/1186bf2352107d92076d22c5f6903e54 to your computer and use it in GitHub Desktop.
Save miladvafaeifard/1186bf2352107d92076d22c5f6903e54 to your computer and use it in GitHub Desktop.
nodejs Zip pipeline
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