Skip to content

Commit 4545cc1

Browse files
committed
doc: improve buf.fill() documentation
* Improve prepositions. * Wrap at 80 characters. * Formalize colloquial text. * Remove unnecessary sentence. * Use colons to introduce example code. PR-URL: #19846 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent a639ec4 commit 4545cc1

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

doc/api/buffer.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,16 +1164,17 @@ changes:
11641164
description: The `encoding` parameter is supported now.
11651165
-->
11661166

1167-
* `value` {string|Buffer|integer} The value to fill `buf` with.
1168-
* `offset` {integer} Number of bytes to skip before starting to fill `buf`. **Default:** `0`.
1169-
* `end` {integer} Where to stop filling `buf` (not inclusive). **Default:** [`buf.length`].
1170-
* `encoding` {string} If `value` is a string, this is its encoding.
1167+
* `value` {string|Buffer|integer} The value with which to fill `buf`.
1168+
* `offset` {integer} Number of bytes to skip before starting to fill `buf`.
1169+
**Default:** `0`.
1170+
* `end` {integer} Where to stop filling `buf` (not inclusive). **Default:**
1171+
[`buf.length`].
1172+
* `encoding` {string} The encoding for `value` if `value` is a string.
11711173
**Default:** `'utf8'`.
11721174
* Returns: {Buffer} A reference to `buf`.
11731175

11741176
Fills `buf` with the specified `value`. If the `offset` and `end` are not given,
1175-
the entire `buf` will be filled. This is meant to be a small simplification to
1176-
allow the creation and filling of a `Buffer` to be done on a single line.
1177+
the entire `buf` will be filled:
11771178

11781179
```js
11791180
// Fill a `Buffer` with the ASCII character 'h'.
@@ -1184,10 +1185,10 @@ console.log(b.toString());
11841185
// Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
11851186
```
11861187

1187-
`value` is coerced to a `uint32` value if it is not a String or Integer.
1188+
`value` is coerced to a `uint32` value if it is not a string or integer.
11881189

11891190
If the final write of a `fill()` operation falls on a multi-byte character,
1190-
then only the first bytes of that character that fit into `buf` are written.
1191+
then only the bytes of that character that fit into `buf` are written:
11911192

11921193
```js
11931194
// Fill a `Buffer` with a two-byte character.

0 commit comments

Comments
 (0)