Skip to content

Instantly share code, notes, and snippets.

@bcomnes
Created June 10, 2017 17:24
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 bcomnes/e99784675d446e420cad0d3c5a1dae75 to your computer and use it in GitHub Desktop.
Save bcomnes/e99784675d446e420cad0d3c5a1dae75 to your computer and use it in GitHub Desktop.
from-buffer.js
var from = require('from2')
exports.fromBuffer = fromBuffer
function fromBuffer (buffer) {
return from(function (size, next) {
if (buffer.length <= 0) return next(null, null)
var chunk = buffer.slice(0, size)
buffer = buffer.slice(size)
next(null, chunk)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment