Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created January 25, 2013 01:58
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 Raynos/25bbda49a2bf6fbdbf5e to your computer and use it in GitHub Desktop.
Save Raynos/25bbda49a2bf6fbdbf5e to your computer and use it in GitHub Desktop.
function takeWhile(stream, iterator) {
var s = through(function (chunk) {
var keepReading = iterator(chunk)
if (keepReading === false) {
stream.destroy()
this.emit("end")
}
})
return stream.pipe(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment