Skip to content

Instantly share code, notes, and snippets.

@rajat1saxena
Created August 6, 2017 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajat1saxena/8810fb17d60de3756f4596cbc4b55b4b to your computer and use it in GitHub Desktop.
Save rajat1saxena/8810fb17d60de3756f4596cbc4b55b4b to your computer and use it in GitHub Desktop.
// Simple example to read a file line by line and multiply values by 2 and write
// to an output file
'use strict';
const stream = require('stream');
// const readStream = new ReadStream({
// read(size) {
// if ()
// }
// });
const input = process.stdin;
const output = new stream.Writable({
write(chunk, enc, cb) {
process.stdout.write(`${chunk}: ${chunk.length}`);
cb();
}
});
input.on('end', () => {
console.log('Bye!');
});
input.pipe(output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment