Created
August 6, 2017 17:00
-
-
Save rajat1saxena/8810fb17d60de3756f4596cbc4b55b4b to your computer and use it in GitHub Desktop.
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
// 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