Skip to content
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

Merged
merged 3 commits into from
Jun 1, 2018
Merged

Put Buffer polyfills in a list #1674

merged 3 commits into from
Jun 1, 2018

Conversation

LinusU
Copy link
Contributor

@LinusU LinusU commented May 31, 2018

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.

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
Copy link
Contributor

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.

Copy link
Contributor

@ckotzbauer ckotzbauer left a 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,
Copy link
Contributor

@daxlab daxlab May 31, 2018

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

with this approach

Copy link
Member

@fhinkel fhinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@Trott Trott merged commit 6aaedb2 into master Jun 1, 2018
@WaleedAshraf WaleedAshraf deleted the update-buffer-guide branch June 1, 2018 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants