blob-to-buffer
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/blob-to-buffer package

1.2.9 • Public • Published

blob-to-buffer travis npm downloads javascript style guide

Convert a Blob to a Buffer.

Sauce Test Status

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!

install

npm install blob-to-buffer

usage

var toBuffer = require('blob-to-buffer')
 
// Get a Blob somehow...
var blob = new Blob([ new Uint8Array([1, 2, 3]) ], { type: 'application/octet-binary' })
 
toBuffer(blob, function (err, buffer) {
  if (err) throw err
 
  buffer[0] // => 1
  buffer.readUInt8(1) // => 2
})

license

MIT. Copyright (c) Feross Aboukhadijeh.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.2.9
    37,578
    • latest

Version History

Package Sidebar

Install

npm i blob-to-buffer

Weekly Downloads

40,658

Version

1.2.9

License

MIT

Unpacked Size

4.74 kB

Total Files

4

Last publish

Collaborators

  • feross