Skip to content

Instantly share code, notes, and snippets.

@brycebaril

brycebaril/s.js Secret

Created December 18, 2013 06:04
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/f608f633307329feb779 to your computer and use it in GitHub Desktop.
Save brycebaril/f608f633307329feb779 to your computer and use it in GitHub Desktop.
var spigot = require("stream-spigot")
var through2 = require("through2")
var terminus = require("terminus")
var mb = require("multibuffer")
var count = 0
spigot(function () {
if (count++ < 3) {
this.push(new Uint8Array())
}
else {
this.push(null)
}
})
.pipe(through2(function (chunk, encoding, callback) {
var zz = mb.pack([chunk])
console.log(zz)
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