Handle Node streams with pipes and use events for user feedback
From Node.js Streams: Everything you need to know
const fs = require('fs');
const zlib = require('zlib');
const file = process.argv[2];
fs.createReadStream(file)
.pipe(zlib.createGzip())
.on('data', () => process.stdout.write('.'))
.pipe(fs.createWriteStream(file + '.zz'))
.on('finish', () => console.log('Done'));
Written by martinhj
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Node streams
Authors
Related Tags
#node streams
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#