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

Buffer() without a new keyword is going to be hard-deprecated soon #10

Open
ChALkeR opened this issue Aug 19, 2016 · 4 comments · May be fixed by #38
Open

Buffer() without a new keyword is going to be hard-deprecated soon #10

ChALkeR opened this issue Aug 19, 2016 · 4 comments · May be fixed by #38

Comments

@ChALkeR
Copy link
Contributor

ChALkeR commented Aug 19, 2016

Refs: nodejs/node#8169, nodejs/node#7152.

Two options here:

  • Use the new Buffer API — Buffer.alloc()/Buffer.from()/Buffer.allocUnsafe() (requires a shim for v0.10/v0.12 and older v4.x versions prior to v4.5.0).
  • Use new Buffer() for the time being — just add the new keyword everywhere. You should manually check that everything is safe in this case, see the links below for more explanation. That might be hard-deprecated at some later point.

More background:

Quick grep (you should better re-check):

duplexify-3.4.5.tgz/test.js:279:      t.same(chunk, Buffer('hello world'))
duplexify-3.4.5.tgz/test.js:290:    dup.write(Buffer('hello world'))

The grep above only includes the lines that call Buffer() without the new keyword, if you choose to move to the new API — you should probably also replace new Buffer(…) calls.

@ChALkeR
Copy link
Contributor Author

ChALkeR commented Aug 25, 2016

Note: the deprecation was landed and will start printing warnings in Node.js 7.0.

@ghost
Copy link

ghost commented Nov 4, 2016

node 7 is bad. This is a bad upstream change.

@Trott
Copy link

Trott commented Mar 21, 2018

This can be closed because the deprecation was reverted in a later 7.x release.

@jacobq
Copy link

jacobq commented Jul 19, 2018

I think this can be closed now since new Buffer only gets called if Buffer.from does not exist.

@jimmywarting jimmywarting linked a pull request Sep 20, 2021 that will close this issue
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 a pull request may close this issue.

3 participants