Skip to content

Instantly share code, notes, and snippets.

@1N50MN14
Last active August 29, 2015 14:02
Show Gist options
  • Save 1N50MN14/b306676a512d3d8c175a to your computer and use it in GitHub Desktop.
Save 1N50MN14/b306676a512d3d8c175a to your computer and use it in GitHub Desktop.
Simple transform stream
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