Created
July 29, 2014 05:11
-
-
Save lakenen/10d2c89f3087b34fbda7 to your computer and use it in GitHub Desktop.
duplex
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'), | |
duplex = require('duplexer') | |
function dosomething() { | |
var input = through(), | |
output = through(), | |
stream = duplex(input, output) | |
output.write('two') | |
input.pipe(output) | |
return stream | |
} | |
var source = through() | |
source.pipe(dosomething()).pipe(process.stdout) | |
source.write('one') | |
// one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment