-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
doc: use Buffer.from() instead of new Buffer() #6367
Conversation
Use new API of Buffer to developers in most documents.
@@ -58,8 +58,8 @@ const StringDecoder = exports.StringDecoder = function(encoding) { | |||
// returned when calling write again with the remaining bytes. | |||
// | |||
// Note: Converting a Buffer containing an orphan surrogate to a String | |||
// currently works, but converting a String to a Buffer (via `new Buffer`, or | |||
// Buffer#write) will replace incomplete surrogates with the unicode | |||
// currently works, but converting a String to a Buffer (via `Buffer.from()`, |
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.
Should it be better that we keep the same writing style as afterwards Buffer#write
and use Buffer#from
here ?
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.
thanks
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.
Buffer#write
is used as a shortcut for Buffer.prototype.write
, so it’s something you can call on a Buffer
instance. Buffer.from()
however needs to be called on the global Buffer
object (just as it is written). So, no, it is correct to leave these as they are.
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.
@addaleax 👍 , but Buffer.from
or Buffer.from()
?
LGTM |
1 similar comment
LGTM |
7da4fd4
to
c7066fb
Compare
LGTM |
Landed in e556dd3 |
Use new API of Buffer to developers in most documents. PR-URL: #6367 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Use new API of Buffer to developers in most documents. PR-URL: #6367 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
I do not believe this api exists on v4.x. please correct me if I am wrong |
new API of Buffer not on v4.x. |
Checklist
Affected core subsystem(s)
doc
Description of change
Use new API of Buffer to developers in most documents.