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 #42

Closed
ChALkeR opened this issue Aug 18, 2016 · 2 comments
Closed

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

ChALkeR opened this issue Aug 18, 2016 · 2 comments

Comments

@ChALkeR
Copy link

ChALkeR commented Aug 18, 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):

deep-equal-1.0.1.tgz/test/cmp.js:82:    t.ok(equal(Buffer('xyz'), Buffer('xyz')));

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
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 Oct 7, 2016

@ChALkeR I found a better alternative here: https://github.com/zubuzon/kewlr. Seems to support this

This issue was closed.
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

No branches or pull requests

1 participant