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: general improvements to string_decoder.md copy #6940

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions doc/api/string_decoder.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const decoder = new StringDecoder('utf8');

decoder.write(Buffer.from([0xE2]));
decoder.write(Buffer.from([0x82]));
console.log(decoder.write(Buffer.from([0xAC])));
console.log(decoder.end(Buffer.from([0xAC])));
```

## Class: new StringDecoder([encoding])
Expand All @@ -50,15 +50,20 @@ added: v0.1.99

Creates a new `StringDecoder` instance.

### stringDecoder.end()
### stringDecoder.end(buffer)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/buffer/[buffer]/

<!-- YAML
added: v0.9.3
-->

* `buffer` {Buffer} A `Buffer` instance.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this (and the same parameter for write()) could be a bit more descriptive, since the type is already obvious. Perhaps "Bytes to decode" or something similar?


Returns any remaining input stored in the internal buffer as a string. Bytes
representing incomplete UTF-8 and UTF-16 characters will be replaced with
substitution characters appropriate for the character encoding.

If the `buffer` argument is provided, one final call to `stringDecoder.write()`
is performed before returning the remaining input.

### stringDecoder.write(buffer)
<!-- YAML
added: v0.1.99
Expand Down