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

doc: use Buffer.from() instead of new Buffer() #6367

Closed
wants to merge 1 commit into from

Conversation

JacksonTian
Copy link
Contributor

@JacksonTian JacksonTian commented Apr 25, 2016

Checklist
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)

doc

Description of change

Use new API of Buffer to developers in most documents.

Use new API of Buffer to developers in most documents.
@mscdex mscdex added buffer Issues and PRs related to the buffer subsystem. doc Issues and PRs related to the documentations. and removed buffer Issues and PRs related to the buffer subsystem. labels Apr 25, 2016
@@ -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()`,
Copy link
Member

@DavidCai1111 DavidCai1111 Apr 25, 2016

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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

Copy link
Member

@addaleax addaleax Apr 25, 2016

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.

Copy link
Member

@DavidCai1111 DavidCai1111 Apr 25, 2016

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() ?

@cjihrig
Copy link
Contributor

cjihrig commented Apr 25, 2016

LGTM

1 similar comment
@jasnell
Copy link
Member

jasnell commented Apr 25, 2016

LGTM

@estliberitas estliberitas force-pushed the master branch 2 times, most recently from 7da4fd4 to c7066fb Compare April 26, 2016 05:23
@ChALkeR
Copy link
Member

ChALkeR commented Apr 26, 2016

LGTM

@JacksonTian
Copy link
Contributor Author

Landed in e556dd3

JacksonTian added a commit that referenced this pull request Apr 27, 2016
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>
Fishrock123 pushed a commit that referenced this pull request May 4, 2016
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>
@MylesBorins
Copy link
Contributor

I do not believe this api exists on v4.x. please correct me if I am wrong

@JacksonTian
Copy link
Contributor Author

JacksonTian commented May 18, 2016

new API of Buffer not on v4.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants