Skip to content

Commit cf34c2c

Browse files
committed
doc: improve buf.lastIndexOf() text
Improve description of `encoding` option. (This change is also applied to `buf.indexOf()`.) Improve punctuation. Wrap at 80 characters. PR-URL: #19904 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent f3f1298 commit cf34c2c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

doc/api/buffer.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -1279,9 +1279,10 @@ changes:
12791279

12801280
* `value` {string|Buffer|Uint8Array|integer} What to search for.
12811281
* `byteOffset` {integer} Where to begin searching in `buf`. **Default:** `0`.
1282-
* `encoding` {string} The encoding of `value` if `value` is a string.
1283-
**Default:** `'utf8'`.
1284-
* Returns: {integer} The index of the first occurrence of `value` in `buf` or
1282+
* `encoding` {string} If `value` is a string, this is the encoding used to
1283+
determine the binary representation of the string that will be searched for in
1284+
`buf`. **Default:** `'utf8'`.
1285+
* Returns: {integer} The index of the first occurrence of `value` in `buf`, or
12851286
`-1` if `buf` does not contain `value`.
12861287

12871288
If `value` is:
@@ -1381,13 +1382,14 @@ changes:
13811382
* `value` {string|Buffer|Uint8Array|integer} What to search for.
13821383
* `byteOffset` {integer} Where to begin searching in `buf`.
13831384
**Default:** [`buf.length`]` - 1`.
1384-
* `encoding` {string} If `value` is a string, this is its encoding.
1385-
**Default:** `'utf8'`.
1386-
* Returns: {integer} The index of the last occurrence of `value` in `buf` or `-1`
1387-
if `buf` does not contain `value`.
1385+
* `encoding` {string} If `value` is a string, this is the encoding used to
1386+
determine the binary representation of the string that will be searched for in
1387+
`buf`. **Default:** `'utf8'`.
1388+
* Returns: {integer} The index of the last occurrence of `value` in `buf`, or
1389+
`-1` if `buf` does not contain `value`.
13881390

1389-
Identical to [`buf.indexOf()`], except `buf` is searched from back to front
1390-
instead of front to back.
1391+
Identical to [`buf.indexOf()`], except the last occurrence of `value` is found
1392+
rather than the first occurrence.
13911393

13921394
```js
13931395
const buf = Buffer.from('this buffer is a buffer');

0 commit comments

Comments
 (0)