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: https://github.com/nodejs/node/pull/19904
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Rich Trott 2018-04-09 15:43:29 -07:00
parent f3f1298980
commit cf34c2c79e

View File

@ -1279,9 +1279,10 @@ changes:
* `value` {string|Buffer|Uint8Array|integer} What to search for. * `value` {string|Buffer|Uint8Array|integer} What to search for.
* `byteOffset` {integer} Where to begin searching in `buf`. **Default:** `0`. * `byteOffset` {integer} Where to begin searching in `buf`. **Default:** `0`.
* `encoding` {string} The encoding of `value` if `value` is a string. * `encoding` {string} If `value` is a string, this is the encoding used to
**Default:** `'utf8'`. determine the binary representation of the string that will be searched for in
* Returns: {integer} The index of the first occurrence of `value` in `buf` or `buf`. **Default:** `'utf8'`.
* Returns: {integer} The index of the first occurrence of `value` in `buf`, or
`-1` if `buf` does not contain `value`. `-1` if `buf` does not contain `value`.
If `value` is: If `value` is:
@ -1381,13 +1382,14 @@ changes:
* `value` {string|Buffer|Uint8Array|integer} What to search for. * `value` {string|Buffer|Uint8Array|integer} What to search for.
* `byteOffset` {integer} Where to begin searching in `buf`. * `byteOffset` {integer} Where to begin searching in `buf`.
**Default:** [`buf.length`]` - 1`. **Default:** [`buf.length`]` - 1`.
* `encoding` {string} If `value` is a string, this is its encoding. * `encoding` {string} If `value` is a string, this is the encoding used to
**Default:** `'utf8'`. determine the binary representation of the string that will be searched for in
* Returns: {integer} The index of the last occurrence of `value` in `buf` or `-1` `buf`. **Default:** `'utf8'`.
if `buf` does not contain `value`. * 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 Identical to [`buf.indexOf()`], except the last occurrence of `value` is found
instead of front to back. rather than the first occurrence.
```js ```js
const buf = Buffer.from('this buffer is a buffer'); const buf = Buffer.from('this buffer is a buffer');