-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you format |
||
to be returned as string of the specified encoding rather than as `Buffer` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add an 'a' before 'string' here too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and before `Buffer` There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Went with |
||
objects. For instance, calling `readable.setEncoding('utf8')` will cause the | ||
output data will be interpreted as UTF-8 data, and passed as strings. Calling | ||
|
@@ -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'); | ||
|
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.
Trailing space should be removed.