Skip to content

Instantly share code, notes, and snippets.

@soldair
Last active December 25, 2015 17:19
Show Gist options
  • Save soldair/7012676 to your computer and use it in GitHub Desktop.
Save soldair/7012676 to your computer and use it in GitHub Desktop.
wrap a pipe chain in an exposed through stream
var through = require('through')
module.exports = function(chain){
chain = chain();
var s = through(function(data){
if(!chain.write(data)) this.pause();
});
chain.on('drain',function(){
s.resume();
})
chain.on('data',function(data){
s.emit('data',data)
});
chain.on('end',function(){
s.end();
});
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment