Skip to content

Instantly share code, notes, and snippets.

@ivoputzer
Created June 8, 2017 18:07
Show Gist options
  • Save ivoputzer/616ff3e1aa94d9b270202f1aea48f572 to your computer and use it in GitHub Desktop.
Save ivoputzer/616ff3e1aa94d9b270202f1aea48f572 to your computer and use it in GitHub Desktop.
bufferFrom.js
function bufferFrom (stream, fn, {concat} = Buffer) {
return buffer = []
, stream.on('data', (data) => buffer.push(data))
.on('end', () => fn(concat(buffer)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment