Skip to content

Put Buffer polyfills in a list#1674

Merged
Trott merged 3 commits into
masterfrom
update-buffer-guide
Jun 1, 2018
Merged

Put Buffer polyfills in a list#1674
Trott merged 3 commits into
masterfrom
update-buffer-guide

Conversation

@LinusU

@LinusU LinusU commented May 31, 2018

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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.

@ckotzbauer ckotzbauer left a comment

Copy link
Copy Markdown
Contributor

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,

@daxlab daxlab May 31, 2018

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

@fhinkel fhinkel left a comment

Copy link
Copy Markdown
Member

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