Skip to content

Commit

Permalink
doc: improve buf.lastIndexOf() text
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Trott authored and targos committed Apr 12, 2018
1 parent bf489cb commit 8531d95
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -1240,9 +1240,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 @@ -1342,13 +1343,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

0 comments on commit 8531d95

Please sign in to comment.