Created
March 18, 2017 21:54
-
-
Save ischenkodv/bcb5151e909c9db7502d3370937e7955 to your computer and use it in GitHub Desktop.
Example of writable stream in NodeJS.
This file contains hidden or 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
const stream = require('stream'); | |
const fs = require('fs'); | |
class EchoStream extends stream.Writable { | |
_write(chunk, enc, next) { | |
console.log(chunk.toString()); | |
next(); | |
} | |
} | |
const echoStream = new EchoStream(); | |
fs.createReadStream('./test.txt').pipe(echoStream); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment