3 ms·
https://github.com/feross/safe-buffer https://github.com/feross/safe-buffer Looks like one of those "utility" modules that get used in a project because there'
by xyst 6y ago
https://github.com/feross/safe-buffer https://github.com/feross/safe-buffer
Looks like one of those "utility" modules that get used in a project because there's no proper standard library for node.js
At least it's better than the infamous "left-pad" module, which was just a single function
- capableweb 6y ago> Looks like one of those "utility" modules that get used in a project because there's no proper standard library for node.js No, not really. Buffer is already part of the standard library for nodejs. What this is, is a "safe" variant of the very same buffers, as the previous ones were found unsafe. Although if you're controlling the runtime, there is no need for safe-buffer package anymore, as Buffer from the standard library is now safe. See https://nodejs.org/en/docs/guides/buffer-constructor-deprecation/ https://nodejs.org/en/docs/guides/buffer-constructor-depreca... for all information around nodejs "safe" buffers. Feross' library is mentioned there as well.
- feross 6y agoThe Buffer security issues that Mathias Buus and I uncovered led to the deprecation of `new Buffer()` in Node.js and the creation of the `Buffer.from()` and `Buffer.alloc()` APIs. There is an explanation here: https://github.com/feross/safe-buffer#why-is-buffer-unsafe https://github.com/feross/safe-buffer#why-is-buffer-unsafe I created `safe-buffer` as a demonstration of how the API could be fixed to be safe. Then, the ecosystem adopted `safe-buffer` as a polyfill to get that safety even before `Buffer.from()` and `Buffer.alloc()` were included in Node.js. And to this day it continues to be used to provide safety in older versions of Node.js which lack the newer APIs.