-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Put Buffer polyfills in a list #1674
Conversation
Per discussion here: https://github.com/nodejs/nodejs.org/pull/1666/files#r191602869 The idea is to give a more equal view of all the options. Removed the drawback about the number of dependencies of `buffer-from` and `buffer-alloc` since those 4 dependencies are smaller than the 1 `safer-buffer`.
A downside with this approach is slightly more code changes to migrate off them (as you would be | ||
using e.g. `Buffer.from` under a different name). | ||
|
||
- **[safe-buffer](https://www.npmjs.com/package/safe-buffer)** is also a drop in replacement for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use "drop-in replacement" to be consistent with above spelling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with above spelling fix ;)
You would take exactly the same steps as in [Variant 1](#variant-1), but with a polyfill | ||
`const Buffer = require('safer-buffer').Buffer` in all files where you use the new `Buffer` API. | ||
|
||
Make sure that you do not use old `new Buffer` API — in any files where the line above is added, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
- in any file
- where above line is added
- **[safe-buffer](https://www.npmjs.com/package/safe-buffer)** is also a drop in replacement for | ||
the entire `Buffer` API, but using `new Buffer()` will still work as before. | ||
|
||
A downside to this approach is that it will allow you to also use the older `new Buffer()` API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
with this approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Per discussion here:
https://github.com/nodejs/nodejs.org/pull/1666/files#r191602869
The idea is to give a more equal view of all the options.
Removed the drawback about the number of dependencies of
buffer-from
andbuffer-alloc
since those 4 dependencies are smaller than the 1safer-buffer
.