Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: improve buf.lastIndexOf() text #19904

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -1279,9 +1279,10 @@ changes:

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

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

Identical to [`buf.indexOf()`], except `buf` is searched from back to front
instead of front to back.
Identical to [`buf.indexOf()`], except the last occurrence of `value` is found
rather than the first occurrence.

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