Skip to content

Commit 28e5c46

Browse files
committed
doc: improve buf.indexOf() documentation style
* improve usage of "coerce" in buffer.md * reduce informal tone in buffer.md * wrap line at 80 characters in buffer.md * wrap value in backtick for consistency PR-URL: #19861 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent eec659c commit 28e5c46

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

doc/api/buffer.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,10 +1259,10 @@ changes:
12591259

12601260
* `value` {string|Buffer|Uint8Array|integer} What to search for.
12611261
* `byteOffset` {integer} Where to begin searching in `buf`. **Default:** `0`.
1262-
* `encoding` {string} If `value` is a string, this is its encoding.
1262+
* `encoding` {string} The encoding of `value` if `value` is a string.
12631263
**Default:** `'utf8'`.
1264-
* Returns: {integer} The index of the first occurrence of `value` in `buf` or `-1`
1265-
if `buf` does not contain `value`.
1264+
* Returns: {integer} The index of the first occurrence of `value` in `buf` or
1265+
`-1` if `buf` does not contain `value`.
12661266

12671267
If `value` is:
12681268

@@ -1301,9 +1301,9 @@ If `value` is not a string, number, or `Buffer`, this method will throw a
13011301
`TypeError`. If `value` is a number, it will be coerced to a valid byte value,
13021302
an integer between 0 and 255.
13031303

1304-
If `byteOffset` is not a number, it will be coerced to a number. Any arguments
1305-
that coerce to `NaN` or 0, like `{}`, `[]`, `null` or `undefined`, will search
1306-
the whole buffer. This behavior matches [`String#indexOf()`].
1304+
If `byteOffset` is not a number, it will be coerced to a number. If the result
1305+
of coercion is `NaN` or `0`, then the entire buffer will be searched. This
1306+
behavior matches [`String#indexOf()`].
13071307

13081308
```js
13091309
const b = Buffer.from('abcdef');

0 commit comments

Comments
 (0)