Skip to content

Commit

Permalink
doc: improve buf.write() text in buffer.md
Browse files Browse the repository at this point in the history
* Use present tense consistently in parameters description.
* Wrap at 80 characters.
* "partial amount of `string`" -> "part of `string`"
* Unnecessary `Buffer.allocUnsafe()` changed to `Buffer.alloc()`.

PR-URL: #20115
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
Trott authored and jasnell committed Apr 20, 2018
1 parent 655ab65 commit 193d808
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -2074,19 +2074,21 @@ for (const value of buf) {
added: v0.1.90
-->

* `string` {string} String to be written to `buf`.
* `offset` {integer} Number of bytes to skip before starting to write `string`. **Default:** `0`.
* `length` {integer} Number of bytes to write. **Default:** `buf.length - offset`.
* `string` {string} String to write to `buf`.
* `offset` {integer} Number of bytes to skip before starting to write `string`.
**Default:** `0`.
* `length` {integer} Number of bytes to write. **Default:**
`buf.length - offset`.
* `encoding` {string} The character encoding of `string`. **Default:** `'utf8'`.
* Returns: {integer} Number of bytes written.

Writes `string` to `buf` at `offset` according to the character encoding in `encoding`.
The `length` parameter is the number of bytes to write. If `buf` did not contain
enough space to fit the entire string, only a partial amount of `string` will
be written. However, partially encoded characters will not be written.
Writes `string` to `buf` at `offset` according to the character encoding in
`encoding`. The `length` parameter is the number of bytes to write. If `buf` did
not contain enough space to fit the entire string, only part of `string` will be
written. However, partially encoded characters will not be written.

```js
const buf = Buffer.allocUnsafe(256);
const buf = Buffer.alloc(256);

const len = buf.write('\u00bd + \u00bc = \u00be', 0);

Expand Down

0 comments on commit 193d808

Please sign in to comment.