Say you're using the 'buffer' module on npm, or browserify and you're working with lots of binary data.
Unfortunately, sometimes the browser or someone else's API gives you a Blob
. Silly browser. How do you convert it to a Buffer
?
Something with a goofy FileReader
thingy... Time to Google for it yet again... There must be a better way!
There is! Simply use this module!
Works in the browser. This module is used by WebTorrent!
installnpm install blob-to-buffer
usage
licensevar toBuffer = require('blob-to-buffer')
Â
var blob = new Blob([ new Uint8Array([1, 2, 3]) ], { type: 'application/octet-binary' })
Â
toBuffer(blob, function (err, buffer) {
  if (err) throw err
Â
  buffer[0]Â
  buffer.readUInt8(1)Â
})
MIT. Copyright (c) Feross Aboukhadijeh.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4