Last active
December 20, 2015 02:29
-
-
Save shama/6056829 to your computer and use it in GitHub Desktop.
through stream
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
var through = require('through'); | |
var split = require('split'); | |
var a = through(function write(data) { | |
// We handle the data internally here | |
this.queue('line: ' + data + '\n'); | |
}); | |
a.pipe(process.stdout); | |
var exposed = through(); | |
exposed.pipe(split()).pipe(a); | |
// some other stream | |
var b = through(function write(data) { | |
// do something with b data here | |
this.queue(data); | |
}); | |
exposed.write('omg test 123\nomg test 456\nomg test 789\n'); | |
b.pipe(exposed); | |
b.write('omg test 1313213456\n'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment