Skip to content

Instantly share code, notes, and snippets.

@shama
Last active December 20, 2015 02:29
Show Gist options
  • Save shama/6056829 to your computer and use it in GitHub Desktop.
Save shama/6056829 to your computer and use it in GitHub Desktop.
through stream
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