From 28e5c462d4f65dca3d0153a5df314f0d4c5c4a84 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 6 Apr 2018 21:20:51 -0700 Subject: doc: improve buf.indexOf() documentation style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 Reviewed-By: Vse Mozhet Byt Reviewed-By: Trivikram Kamat Reviewed-By: Gibson Fahnestock Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Benjamin Gruenbaum --- doc/api/buffer.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'doc/api/buffer.md') 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'); -- cgit v1.2.3