by xyst · 6y ago · 0 comments
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
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-depreca... for all information around nodejs "safe" buffers. Feross' library is mentioned there as well.
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.