diff options
author | Rich Trott <rtrott@gmail.com> | 2018-04-06 21:20:51 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-04-09 15:20:03 -0700 |
commit | 28e5c462d4f65dca3d0153a5df314f0d4c5c4a84 (patch) | |
tree | 0187c807da1c81d2097e57b97383c1b19a78da57 /doc/api/buffer.md | |
parent | eec659c138f3afcd51a25cd8b197d715a47baa65 (diff) | |
download | android-node-v8-28e5c462d4f65dca3d0153a5df314f0d4c5c4a84.tar.gz android-node-v8-28e5c462d4f65dca3d0153a5df314f0d4c5c4a84.tar.bz2 android-node-v8-28e5c462d4f65dca3d0153a5df314f0d4c5c4a84.zip |
doc: improve buf.indexOf() documentation style
* improve usage of "coerce" in buffer.md
* reduce informal tone in buffer.md
* wrap line at 80 characters in buffer.md
* wrap value in backtick for consistency
PR-URL: https://github.com/nodejs/node/pull/19861
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'doc/api/buffer.md')
-rw-r--r-- | doc/api/buffer.md | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/doc/api/buffer.md b/doc/api/buffer.md index b6db1032ad..2ea989e7fe 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -1259,10 +1259,10 @@ changes: * `value` {string|Buffer|Uint8Array|integer} What to search for. * `byteOffset` {integer} Where to begin searching in `buf`. **Default:** `0`. -* `encoding` {string} If `value` is a string, this is its encoding. +* `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 `-1` - if `buf` does not contain `value`. +* Returns: {integer} The index of the first occurrence of `value` in `buf` or + `-1` if `buf` does not contain `value`. If `value` is: @@ -1301,9 +1301,9 @@ If `value` is not a string, number, or `Buffer`, this method will throw a `TypeError`. If `value` is a number, it will be coerced to a valid byte value, an integer between 0 and 255. -If `byteOffset` is not a number, it will be coerced to a number. Any arguments -that coerce to `NaN` or 0, like `{}`, `[]`, `null` or `undefined`, will search -the whole buffer. This behavior matches [`String#indexOf()`]. +If `byteOffset` is not a number, it will be coerced to a number. If the result +of coercion is `NaN` or `0`, then the entire buffer will be searched. This +behavior matches [`String#indexOf()`]. ```js const b = Buffer.from('abcdef'); |