Skip to content

Commit 193d808

Browse files
Trottjasnell
authored andcommitted
doc: improve buf.write() text in buffer.md
* 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>
1 parent 655ab65 commit 193d808

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

doc/api/buffer.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,19 +2074,21 @@ for (const value of buf) {
20742074
added: v0.1.90
20752075
-->
20762076

2077-
* `string` {string} String to be written to `buf`.
2078-
* `offset` {integer} Number of bytes to skip before starting to write `string`. **Default:** `0`.
2079-
* `length` {integer} Number of bytes to write. **Default:** `buf.length - offset`.
2077+
* `string` {string} String to write to `buf`.
2078+
* `offset` {integer} Number of bytes to skip before starting to write `string`.
2079+
**Default:** `0`.
2080+
* `length` {integer} Number of bytes to write. **Default:**
2081+
`buf.length - offset`.
20802082
* `encoding` {string} The character encoding of `string`. **Default:** `'utf8'`.
20812083
* Returns: {integer} Number of bytes written.
20822084

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

20882090
```js
2089-
const buf = Buffer.allocUnsafe(256);
2091+
const buf = Buffer.alloc(256);
20902092

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

0 commit comments

Comments
 (0)