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
base: master
from

Conversation

Projects
None yet
8 participants
@JacksonTian
Contributor

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.

doc: use Buffer.from() instead of new Buffer()
Use new API of Buffer to developers in most documents.

@mscdex mscdex added buffer doc and removed buffer 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()`,

This comment has been minimized.

@DavidCai1993

DavidCai1993 Apr 25, 2016

Member

Should it be better that we keep the same writing style as afterwards Buffer#write and use Buffer#from here ?

@DavidCai1993

DavidCai1993 Apr 25, 2016

Member

Should it be better that we keep the same writing style as afterwards Buffer#write and use Buffer#from here ?

This comment has been minimized.

@JacksonTian

JacksonTian Apr 25, 2016

Contributor

thanks

@JacksonTian

JacksonTian Apr 25, 2016

Contributor

thanks

This comment has been minimized.

@addaleax

addaleax Apr 25, 2016

Member

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.

@addaleax

addaleax Apr 25, 2016

Member

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.

This comment has been minimized.

@DavidCai1993

DavidCai1993 Apr 25, 2016

Member

@addaleax 👍 , but Buffer.from or Buffer.from() ?

@DavidCai1993

DavidCai1993 Apr 25, 2016

Member

@addaleax 👍 , but Buffer.from or Buffer.from() ?

@cjihrig

This comment has been minimized.

Show comment
Hide comment
@cjihrig

cjihrig Apr 25, 2016

Contributor

LGTM

Contributor

cjihrig commented Apr 25, 2016

LGTM

@jasnell

This comment has been minimized.

Show comment
Hide comment
@jasnell

jasnell Apr 25, 2016

Member

LGTM

Member

jasnell commented Apr 25, 2016

LGTM

@ChALkeR

This comment has been minimized.

Show comment
Hide comment
@ChALkeR

ChALkeR Apr 26, 2016

Member

LGTM

Member

ChALkeR commented Apr 26, 2016

LGTM

@JacksonTian

This comment has been minimized.

Show comment
Hide comment
@JacksonTian

JacksonTian Apr 27, 2016

Contributor

Landed in e556dd3

Contributor

JacksonTian commented Apr 27, 2016

Landed in e556dd3

JacksonTian added a commit that referenced this pull request Apr 27, 2016

doc: use Buffer.from() instead of new Buffer()
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 added a commit that referenced this pull request May 4, 2016

doc: use Buffer.from() instead of new Buffer()
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

This comment has been minimized.

Show comment
Hide comment
@MylesBorins

MylesBorins May 18, 2016

Member

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

Member

MylesBorins commented May 18, 2016

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

@JacksonTian

This comment has been minimized.

Show comment
Hide comment
@JacksonTian

JacksonTian May 18, 2016

Contributor

new API of Buffer not on v4.x.

Contributor

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