Last active
August 29, 2015 14:02
-
-
Save 1N50MN14/b306676a512d3d8c175a to your computer and use it in GitHub Desktop.
Simple transform 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
function Through(opts, onData, onEnd) { | |
if (!(this instanceof Through)) return new Through(opts, onData, onEnd) | |
Transform.call(this, opts) | |
this._transform = onData | |
if (typeof onEnd === 'function') this._flush = onEnd | |
} | |
inherits(Through, Transform) | |
function through(opts, onData, onEnd) { | |
if (typeof opts === 'function') { | |
onEnd = onData || null | |
onData = opts | |
opts = {allowHalfOpen: false} | |
} | |
return Through(opts, onData, onEnd) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment