Skip to content

Instantly share code, notes, and snippets.

@davidbanham
Created September 24, 2014 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidbanham/0d81359ed4d8c4a784dc to your computer and use it in GitHub Desktop.
Save davidbanham/0d81359ed4d8c4a784dc to your computer and use it in GitHub Desktop.
You can totally pass functions in a document stream
t2 = require 'through2'
one = t2.obj (doc, enc, cb) ->
doc.speak()
doc.foo = ->
console.log 'foo'
@push doc
cb()
two = t2.obj (doc, enc, cb) ->
doc.foo()
@push doc
cb()
one.pipe two
one.write {speak: -> console.log 'hai'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment