summaryrefslogtreecommitdiff
path: root/doc/api/buffer.md
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2018-04-09 15:43:29 -0700
committerRich Trott <rtrott@gmail.com>2018-04-11 20:26:12 -0700
commitcf34c2c79e73ad6d3eca5ba13a5921077d9083d3 (patch)
tree460d67fe1bb25c0bf3f51acf39cb64f840b79f49 /doc/api/buffer.md
parentf3f129898056244a52aed33b89d0edffc128637a (diff)
downloadandroid-node-v8-cf34c2c79e73ad6d3eca5ba13a5921077d9083d3.tar.gz
android-node-v8-cf34c2c79e73ad6d3eca5ba13a5921077d9083d3.tar.bz2
android-node-v8-cf34c2c79e73ad6d3eca5ba13a5921077d9083d3.zip
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>
Diffstat (limited to 'doc/api/buffer.md')
-rw-r--r--doc/api/buffer.md20
1 files changed, 11 insertions, 9 deletions
diff --git a/doc/api/buffer.md b/doc/api/buffer.md
index fbd7ace6b6..2842b6d7b0 100644
--- a/doc/api/buffer.md
+++ b/doc/api/buffer.md
@@ -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:
@@ -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');