From 60e912374f062b57837b5defa21babb2848049fe Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 6 Apr 2018 21:20:51 -0700 Subject: [PATCH] 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 --- doc/api/buffer.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index d3a92f6d351647..6051b8a03114f4 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -1258,10 +1258,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: @@ -1300,9 +1300,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');