Skip to content

Commit 4a795dd

Browse files
TrottMylesBorins
authored andcommitted
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 <vsemozhetbyt@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 246c2d1 commit 4a795dd

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

doc/api/buffer.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -1325,11 +1325,12 @@ changes:
13251325
-->
13261326

13271327
* `value` {string|Buffer|Uint8Array|integer} What to search for.
1328-
* `byteOffset` {integer} Where to begin searching in `buf`. **Default:** `0`
1329-
* `encoding` {string} If `value` is a string, this is its encoding.
1330-
**Default:** `'utf8'`
1331-
* Returns: {integer} The index of the first occurrence of `value` in `buf` or `-1`
1332-
if `buf` does not contain `value`.
1328+
* `byteOffset` {integer} Where to begin searching in `buf`. **Default:** `0`.
1329+
* `encoding` {string} If `value` is a string, this is the encoding used to
1330+
determine the binary representation of the string that will be searched for in
1331+
`buf`. **Default:** `'utf8'`.
1332+
* Returns: {integer} The index of the first occurrence of `value` in `buf`, or
1333+
`-1` if `buf` does not contain `value`.
13331334

13341335
If `value` is:
13351336

@@ -1438,14 +1439,15 @@ changes:
14381439

14391440
* `value` {string|Buffer|Uint8Array|integer} What to search for.
14401441
* `byteOffset` {integer} Where to begin searching in `buf`.
1441-
**Default:** [`buf.length`]` - 1`
1442-
* `encoding` {string} If `value` is a string, this is its encoding.
1443-
**Default:** `'utf8'`
1444-
* Returns: {integer} The index of the last occurrence of `value` in `buf` or `-1`
1445-
if `buf` does not contain `value`.
1446-
1447-
Identical to [`buf.indexOf()`], except `buf` is searched from back to front
1448-
instead of front to back.
1442+
**Default:** [`buf.length`]` - 1`.
1443+
* `encoding` {string} If `value` is a string, this is the encoding used to
1444+
determine the binary representation of the string that will be searched for in
1445+
`buf`. **Default:** `'utf8'`.
1446+
* Returns: {integer} The index of the last occurrence of `value` in `buf`, or
1447+
`-1` if `buf` does not contain `value`.
1448+
1449+
Identical to [`buf.indexOf()`], except the last occurrence of `value` is found
1450+
rather than the first occurrence.
14491451

14501452
Examples:
14511453

0 commit comments

Comments
 (0)