feross / blob-to-buffer

Convert a Blob to a Buffer.
MIT License
76 stars 13 forks source link

Possibility to supply Buffer constructor #9

Closed perry-mitchell closed 6 years ago

perry-mitchell commented 7 years ago

I was looking at buffer and this on npm and realised that I'd need to have Buffer on the global namespace for it to work with this library. Would you be open to allowing a 3rd parameter to allow for the optional overriding of the Buffer keyword?

This would allow me to use this library in a way that doesn't pollute global.

feross commented 6 years ago

I don't think you'd need to add Buffer to the global namespace. Bundlers like browserify automatically add the buffer package to the bundle when they detect usage of Buffer. For non-browserify bundlers, you might need to configure them to emulate a node-environment to get the correct behavior (e.g. for Rollup, you need rollup-plugin-node-builtins).