Package Exports
- bfs-buffer
- bfs-buffer/js/extended_ascii
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (bfs-buffer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
BrowserFS Buffer v0.1.5
An emulation of NodeJS's Buffer module. Used in BrowserFS.
Features
- Space-efficient binary representation across browsers.
ArrayBufferin modern browsersCanvasPixelArrayin older browsers that do not support typed arrays, but support the canvas.Arrayof 32-bit ints in older browsers without the above.
- Supports the entirety of the NodeJS
BufferAPI! (including string encoding)- ...with a few exceptions, due to browser limitations (see below).
- Well-tested! Passes all of Node's
Buffertests.- The unit tests are located in the BrowserFS repository.
Use with Browserify
This module can be used with Browserify in place of its default Buffer module!
Here's the relevant configuration:
{
builtins:
{
"buffer": require.resolve('bfs-buffer')
},
insertGlobalVars: {
"Buffer": function() { return "require('bfs-buffer').Buffer" }
}
}Limitations
- Does not support array indexing. e.g. you cannot do
buff[0] = 3.- Browsers do not let you implement custom arrays, and merely setting the prototype of
BuffertoUint8Array, as in the official Node implementation ofBuffer, is not portable across browsers.
- Browsers do not let you implement custom arrays, and merely setting the prototype of