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

Update stream.md - fix issue in setEncoding method #11363

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -911,10 +911,11 @@ added: v0.9.4
* `encoding` {String} The encoding to use.
* Returns: `this`

The `readable.setEncoding()` method sets the default character encoding for
data read from the Readable stream.
The `readable.setEncoding()` method sets the character encoding for
data read from the Readable stream.
Copy link
Contributor

Choose a reason for hiding this comment

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

Trailing space should be removed.


Setting an encoding causes the stream data
By default, no encoding is assigned and stream data will be returned as
Buffer objects. Setting an encoding causes the stream data
Copy link
Contributor

Choose a reason for hiding this comment

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

Double space after the period should be a single space (IMHO and to match the surrounding text).

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you format Buffer as inline code.

to be returned as string of the specified encoding rather than as `Buffer`
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add an 'a' before 'string' here too?

Copy link
Contributor

Choose a reason for hiding this comment

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

and before `Buffer`

Copy link
Member

Choose a reason for hiding this comment

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

Can you add an 'a' before 'string' here too?

Went with strings and Buffers instead (to match the rest of the paragraph).

objects. For instance, calling `readable.setEncoding('utf8')` will cause the
output data will be interpreted as UTF-8 data, and passed as strings. Calling
Expand All @@ -925,10 +926,6 @@ The Readable stream will properly handle multi-byte characters delivered through
the stream that would otherwise become improperly decoded if simply pulled from
the stream as `Buffer` objects.

Encoding can be disabled by calling `readable.setEncoding(null)`. This approach
is useful when working with binary data or with large multi-byte strings spread
out over multiple chunks.

```js
const readable = getReadableStreamSomehow();
readable.setEncoding('utf8');
Expand Down