Skip to content

Instantly share code, notes, and snippets.

@lakenen
Created July 29, 2014 05:11
Show Gist options
  • Save lakenen/10d2c89f3087b34fbda7 to your computer and use it in GitHub Desktop.
Save lakenen/10d2c89f3087b34fbda7 to your computer and use it in GitHub Desktop.
duplex
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