Skip to content

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

Closed
JacksonTian wants to merge 1 commit into
nodejs:masterfrom
JacksonTian:doc_buffer
Closed

doc: use Buffer.from() instead of new Buffer()#6367
JacksonTian wants to merge 1 commit into
nodejs:masterfrom
JacksonTian:doc_buffer

Conversation

@JacksonTian

@JacksonTianJacksonTian commented Apr 25, 2016

Copy link
Copy Markdown
Contributor
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.
@mscdexmscdex 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
Comment threadlib/string_decoder.js
// 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()`,

@DavidCai1111DavidCai1111Apr 25, 2016

Copy link
Copy Markdown
Member

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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

thanks

@addaleaxaddaleaxApr 25, 2016

Copy link
Copy Markdown
Member

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.

@DavidCai1111DavidCai1111Apr 25, 2016

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor

LGTM

1 similar comment
@jasnell

Copy link
Copy Markdown
Member

LGTM

@estliberitas
estliberitasforce-pushed the master branch 2 times, most recently from 7da4fd4 to c7066fbCompareApril 26, 2016 05:23
@ChALkeR

Copy link
Copy Markdown
Member

LGTM

@JacksonTian

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
Contributor

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

@JacksonTian

JacksonTian commented May 18, 2016

Copy link
Copy Markdown
ContributorAuthor

new API of Buffer not on v4.x.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docIssues and PRs related to the documentations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@JacksonTian@cjihrig@jasnell@ChALkeR@MylesBorins@addaleax@DavidCai1111@mscdex