Skip to content

Instantly share code, notes, and snippets.

@brycebaril
Created December 18, 2013 05:33
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 brycebaril/8017727 to your computer and use it in GitHub Desktop.
Save brycebaril/8017727 to your computer and use it in GitHub Desktop.
poor-man's multibuffer-stream
var spigot = require("stream-spigot")
var through2 = require("through2")
var terminus = require("terminus")
var mb = require("multibuffer")
spigot(["aaaaaaaaaaa", "bbbbbbbbbbbb", "cccccccccccccccc"])
.pipe(through2(function (chunk, encoding, callback) {
this.push(mb.pack([chunk]))
callback()
}))
.pipe(through2(function (chunk, encoding, callback) {
this.push(mb.unpack(chunk)[0])
callback()
}))
.pipe(terminus.tail(function (piece) {
console.log("got: " + piece.toString())
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment