-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
Use Buffer.from instead of 'new Buffer' #175
Conversation
Buffer() constructor is deprecated. Refs: https://nodejs.org/api/deprecations.html#deprecations_dep0005_buffer_constructor
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. Also, there should be no compatibility concerns, given that node-tar already uses Buffer.alloc()
extensively.
Tracking: nodejs/node#19079 |
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.
We can't do this unless it uses safe-buffer
as well, because this breaks in node@>4 <4.5
. If you can add that dep and put const Buffer = require('safe-buffer').Buffer
, that'd be handy!
As @ChALkeR said, this library already drops support for Node.js < 4.5. https://github.com/npm/node-tar/blob/a561d633e219d912fcf61606566fa2c6e35332fb/package.json#L38 |
@zkat Hi! I think you made a mistake here — this package doesn't work on Node.js < 4.5.0 and doesn't declare support for it. I already mentioned that in my PR.
@isaacs merged both of those separately, so I suppose that's deliberate. |
@zkat Ping? |
Ah, I didn't realize. /cc @isaacs 'cause we should support this, and it's fairly trivial to have |
@zkat Does this PR need to be blocked on that? |
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.
I guess not. I thought we'd changed things so npm ran in pre-4.5 node, but that doesn't seem to be the case. And we're dropping node@4
support now with npm@6
anyway.
@zkat Thanks! 👍 |
Updated node-tar so this is no longer an issue. Should work fine in every node >=4.0.0. It's weird that we were apparently already not working in Node 4.x <4.5.0 for a while, and hadn't heard about it. I guess people tend to stick to the tip of their major branch? |
@isaacs Thanks! I have not included the tests because I am mass-filing these PRs, and users won't observe the warnings from tests =). Per nodejs/node#19079 (comment) I am also now sending lists of per-owner affected packages via Gitter. |
Buffer()
constructor is deprecated.Refs: https://nodejs.org/api/deprecations.html#deprecations_dep0005_buffer_constructor
Note: this does not cover tests/benchmarks.
Supported Node.js range is not affected,
Buffer.alloc
is used already and the minimum required Node.js version is 4.5.0.This is one of the three changes needed to keep
npm i
working underNODE_PENDING_DEPRECATION=1
without warnings. The other two are mafintosh/flush-write-stream#3 and mafintosh/duplexify#17.