-
-
Notifications
You must be signed in to change notification settings - Fork 624
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
#380
Comments
yep, I saw original safe alloc discussion, thanks for heads up! |
@ChALkeR did you use some custom script or eslint to log this? I'd like to add test rule so that it's not accidentally introduced in the future |
@sidorares No, I don't have an eslint rule for that, sorry, and am not aware of any. It would be super-awesome if you would find one, though =). |
Status update: the deprecation was landed and will start printing warnings in Node.js 7.0 (e.g. for older versions that didn't receive the patch). Thanks for the fast reaction, btw! =) |
Refs: nodejs/node#8169, nodejs/node#7152.
Two options here:
Buffer.alloc()
/Buffer.from()
/Buffer.allocUnsafe()
(requires a shim for v0.10/v0.12 and older v4.x versions prior to v4.5.0).new Buffer()
for the time being — just add thenew
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):
The grep above only includes the lines that call
Buffer()
without thenew
keyword, if you choose to move to the new API — you should probably also replacenew Buffer(…)
calls.The text was updated successfully, but these errors were encountered: