Skip to content

Commit dbcc7bd

Browse files
silverwindgibfahn
authored andcommitted
doc: consistent case for primitive types
PR-URL: #11167 Backport-PR-URL: #13054 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent adb9bfb commit dbcc7bd

21 files changed

+515
-434
lines changed

doc/api/buffer.md

Lines changed: 79 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,8 @@ deprecated: v6.0.0
424424
> Stability: 0 - Deprecated:
425425
> Use [`Buffer.from(string[, encoding])`][`Buffer.from(string)`] instead.
426426
427-
* `string` {String} String to encode
428-
* `encoding` {String} The encoding of `string`. **Default:** `'utf8'`
427+
* `string` {string} String to encode
428+
* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`
429429

430430
Creates a new `Buffer` containing the given JavaScript string `string`. If
431431
provided, the `encoding` parameter identifies the character encoding of `string`.
@@ -454,9 +454,9 @@ added: v5.10.0
454454
-->
455455

456456
* `size` {Integer} The desired length of the new `Buffer`
457-
* `fill` {String | Buffer | Integer} A value to pre-fill the new `Buffer` with.
457+
* `fill` {string | Buffer | Integer} A value to pre-fill the new `Buffer` with.
458458
**Default:** `0`
459-
* `encoding` {String} If `fill` is a string, this is its encoding.
459+
* `encoding` {string} If `fill` is a string, this is its encoding.
460460
**Default:** `'utf8'`
461461

462462
Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the
@@ -609,9 +609,9 @@ A `TypeError` will be thrown if `size` is not a number.
609609
added: v0.1.90
610610
-->
611611

612-
* `string` {String | Buffer | TypedArray | DataView | ArrayBuffer} A value to
612+
* `string` {string | Buffer | TypedArray | DataView | ArrayBuffer} A value to
613613
calculate the length of
614-
* `encoding` {String} If `string` is a string, this is its encoding.
614+
* `encoding` {string} If `string` is a string, this is its encoding.
615615
**Default:** `'utf8'`
616616
* Returns: {Integer} The number of bytes contained within `string`
617617

@@ -805,8 +805,8 @@ A `TypeError` will be thrown if `buffer` is not a `Buffer`.
805805
added: v5.10.0
806806
-->
807807

808-
* `string` {String} A string to encode.
809-
* `encoding` {String} The encoding of `string`. **Default:** `'utf8'`
808+
* `string` {string} A string to encode.
809+
* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`
810810

811811
Creates a new `Buffer` containing the given JavaScript string `string`. If
812812
provided, the `encoding` parameter identifies the character encoding of `string`.
@@ -846,7 +846,7 @@ Returns `true` if `obj` is a `Buffer`, `false` otherwise.
846846
added: v0.9.1
847847
-->
848848

849-
* `encoding` {String} A character encoding name to check
849+
* `encoding` {string} A character encoding name to check
850850
* Returns: {Boolean}
851851

852852
Returns `true` if `encoding` contains a supported character encoding, or `false`
@@ -1075,10 +1075,10 @@ console.log(buf1.equals(buf3));
10751075
added: v0.5.0
10761076
-->
10771077

1078-
* `value` {String | Buffer | Integer} The value to fill `buf` with
1078+
* `value` {string | Buffer | Integer} The value to fill `buf` with
10791079
* `offset` {Integer} Where to start filling `buf`. **Default:** `0`
10801080
* `end` {Integer} Where to stop filling `buf` (not inclusive). **Default:** [`buf.length`]
1081-
* `encoding` {String} If `value` is a string, this is its encoding.
1081+
* `encoding` {string} If `value` is a string, this is its encoding.
10821082
**Default:** `'utf8'`
10831083
* Returns: {Buffer} A reference to `buf`
10841084

@@ -1107,14 +1107,55 @@ Example: Fill a `Buffer` with a two-byte character
11071107
console.log(Buffer.allocUnsafe(3).fill('\u0222'));
11081108
```
11091109

1110+
### buf.includes(value[, byteOffset][, encoding])
1111+
<!-- YAML
1112+
added: v5.3.0
1113+
-->
1114+
1115+
* `value` {string | Buffer | Integer} What to search for
1116+
* `byteOffset` {Integer} Where to begin searching in `buf`. **Default:** `0`
1117+
* `encoding` {string} If `value` is a string, this is its encoding.
1118+
**Default:** `'utf8'`
1119+
* Returns: {Boolean} `true` if `value` was found in `buf`, `false` otherwise
1120+
1121+
Equivalent to [`buf.indexOf() !== -1`][`buf.indexOf()`].
1122+
1123+
Examples:
1124+
1125+
```js
1126+
const buf = Buffer.from('this is a buffer');
1127+
1128+
// Prints: true
1129+
console.log(buf.includes('this'));
1130+
1131+
// Prints: true
1132+
console.log(buf.includes('is'));
1133+
1134+
// Prints: true
1135+
console.log(buf.includes(Buffer.from('a buffer')));
1136+
1137+
// Prints: true
1138+
// (97 is the decimal ASCII value for 'a')
1139+
console.log(buf.includes(97));
1140+
1141+
// Prints: false
1142+
console.log(buf.includes(Buffer.from('a buffer example')));
1143+
1144+
// Prints: true
1145+
console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));
1146+
1147+
// Prints: false
1148+
console.log(buf.includes('this', 4));
1149+
```
1150+
11101151
### buf.indexOf(value[, byteOffset][, encoding])
11111152
<!-- YAML
11121153
added: v1.5.0
11131154
-->
11141155

11151156
* `value` {String | Buffer | Integer} What to search for
11161157
* `byteOffset` {Integer} Where to begin searching in `buf`. **Default:** `0`
1117-
* `encoding` {String} If `value` is a string, this is its encoding.
1158+
* `encoding` {string} If `value` is a string, this is its encoding.
11181159
**Default:** `'utf8'`
11191160
* Returns: {Integer} The index of the first occurrence of `value` in `buf` or `-1`
11201161
if `buf` does not contain `value`
@@ -1261,7 +1302,7 @@ added: v6.0.0
12611302
* `value` {String | Buffer | Integer} What to search for
12621303
* `byteOffset` {Integer} Where to begin searching in `buf`.
12631304
**Default:** [`buf.length`]` - 1`
1264-
* `encoding` {String} If `value` is a string, this is its encoding.
1305+
* `encoding` {string} If `value` is a string, this is its encoding.
12651306
**Default:** `'utf8'`
12661307
* Returns: {Integer} The index of the last occurrence of `value` in `buf` or `-1`
12671308
if `buf` does not contain `value`
@@ -1385,7 +1426,7 @@ added: v0.11.15
13851426
-->
13861427

13871428
* `offset` {Integer} Where to start reading. Must satisfy: `0 <= offset <= buf.length - 8`
1388-
* `noAssert` {Boolean} Skip `offset` validation? **Default:** `false`
1429+
* `noAssert` {boolean} Skip `offset` validation? **Default:** `false`
13891430
* Returns: {Number}
13901431

13911432
Reads a 64-bit double from `buf` at the specified `offset` with specified
@@ -1421,7 +1462,7 @@ added: v0.11.15
14211462
-->
14221463

14231464
* `offset` {Integer} Where to start reading. Must satisfy: `0 <= offset <= buf.length - 4`
1424-
* `noAssert` {Boolean} Skip `offset` validation? **Default:** `false`
1465+
* `noAssert` {boolean} Skip `offset` validation? **Default:** `false`
14251466
* Returns: {Number}
14261467

14271468
Reads a 32-bit float from `buf` at the specified `offset` with specified
@@ -1456,7 +1497,7 @@ added: v0.5.0
14561497
-->
14571498

14581499
* `offset` {Integer} Where to start reading. Must satisfy: `0 <= offset <= buf.length - 1`
1459-
* `noAssert` {Boolean} Skip `offset` validation? **Default:** `false`
1500+
* `noAssert` {boolean} Skip `offset` validation? **Default:** `false`
14601501
* Returns: {Integer}
14611502

14621503
Reads a signed 8-bit integer from `buf` at the specified `offset`.
@@ -1488,7 +1529,7 @@ added: v0.5.5
14881529
-->
14891530

14901531
* `offset` {Integer} Where to start reading. Must satisfy: `0 <= offset <= buf.length - 2`
1491-
* `noAssert` {Boolean} Skip `offset` validation? **Default:** `false`
1532+
* `noAssert` {boolean} Skip `offset` validation? **Default:** `false`
14921533
* Returns: {Integer}
14931534

14941535
Reads a signed 16-bit integer from `buf` at the specified `offset` with
@@ -1522,7 +1563,7 @@ added: v0.5.5
15221563
-->
15231564

15241565
* `offset` {Integer} Where to start reading. Must satisfy: `0 <= offset <= buf.length - 4`
1525-
* `noAssert` {Boolean} Skip `offset` validation? **Default:** `false`
1566+
* `noAssert` {boolean} Skip `offset` validation? **Default:** `false`
15261567
* Returns: {Integer}
15271568

15281569
Reads a signed 32-bit integer from `buf` at the specified `offset` with
@@ -1557,7 +1598,7 @@ added: v0.11.15
15571598

15581599
* `offset` {Integer} Where to start reading. Must satisfy: `0 <= offset <= buf.length - byteLength`
15591600
* `byteLength` {Integer} How many bytes to read. Must satisfy: `0 < byteLength <= 6`
1560-
* `noAssert` {Boolean} Skip `offset` and `byteLength` validation? **Default:** `false`
1601+
* `noAssert` {boolean} Skip `offset` and `byteLength` validation? **Default:** `false`
15611602
* Returns: {Integer}
15621603

15631604
Reads `byteLength` number of bytes from `buf` at the specified `offset`
@@ -1588,7 +1629,7 @@ added: v0.5.0
15881629
-->
15891630

15901631
* `offset` {Integer} Where to start reading. Must satisfy: `0 <= offset <= buf.length - 1`
1591-
* `noAssert` {Boolean} Skip `offset` validation? **Default:** `false`
1632+
* `noAssert` {boolean} Skip `offset` validation? **Default:** `false`
15921633
* Returns: {Integer}
15931634

15941635
Reads an unsigned 8-bit integer from `buf` at the specified `offset`.
@@ -1618,7 +1659,7 @@ added: v0.5.5
16181659
-->
16191660

16201661
* `offset` {Integer} Where to start reading. Must satisfy: `0 <= offset <= buf.length - 2`
1621-
* `noAssert` {Boolean} Skip `offset` validation? **Default:** `false`
1662+
* `noAssert` {boolean} Skip `offset` validation? **Default:** `false`
16221663
* Returns: {Integer}
16231664

16241665
Reads an unsigned 16-bit integer from `buf` at the specified `offset` with
@@ -1656,7 +1697,7 @@ added: v0.5.5
16561697
-->
16571698

16581699
* `offset` {Integer} Where to start reading. Must satisfy: `0 <= offset <= buf.length - 4`
1659-
* `noAssert` {Boolean} Skip `offset` validation? **Default:** `false`
1700+
* `noAssert` {boolean} Skip `offset` validation? **Default:** `false`
16601701
* Returns: {Integer}
16611702

16621703
Reads an unsigned 32-bit integer from `buf` at the specified `offset` with
@@ -1689,7 +1730,7 @@ added: v0.11.15
16891730

16901731
* `offset` {Integer} Where to start reading. Must satisfy: `0 <= offset <= buf.length - byteLength`
16911732
* `byteLength` {Integer} How many bytes to read. Must satisfy: `0 < byteLength <= 6`
1692-
* `noAssert` {Boolean} Skip `offset` and `byteLength` validation? **Default:** `false`
1733+
* `noAssert` {boolean} Skip `offset` and `byteLength` validation? **Default:** `false`
16931734
* Returns: {Integer}
16941735

16951736
Reads `byteLength` number of bytes from `buf` at the specified `offset`
@@ -1871,7 +1912,7 @@ for working with 64-bit floats.
18711912
added: v0.1.90
18721913
-->
18731914

1874-
* `encoding` {String} The character encoding to decode to. **Default:** `'utf8'`
1915+
* `encoding` {string} The character encoding to decode to. **Default:** `'utf8'`
18751916
* `start` {Integer} The byte offset to start decoding at. **Default:** `0`
18761917
* `end` {Integer} The byte offset to stop decoding at (not inclusive).
18771918
**Default:** [`buf.length`]
@@ -1981,10 +2022,10 @@ for (const value of buf) {
19812022
added: v0.1.90
19822023
-->
19832024

1984-
* `string` {String} String to be written to `buf`
2025+
* `string` {string} String to be written to `buf`
19852026
* `offset` {Integer} Where to start writing `string`. **Default:** `0`
19862027
* `length` {Integer} How many bytes to write. **Default:** `buf.length - offset`
1987-
* `encoding` {String} The character encoding of `string`. **Default:** `'utf8'`
2028+
* `encoding` {string} The character encoding of `string`. **Default:** `'utf8'`
19882029
* Returns: {Integer} Number of bytes written
19892030

19902031
Writes `string` to `buf` at `offset` according to the character encoding in `encoding`.
@@ -2009,9 +2050,9 @@ console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);
20092050
added: v0.11.15
20102051
-->
20112052

2012-
* `value` {Number} Number to be written to `buf`
2053+
* `value` {number} Number to be written to `buf`
20132054
* `offset` {Integer} Where to start writing. Must satisfy: `0 <= offset <= buf.length - 8`
2014-
* `noAssert` {Boolean} Skip `value` and `offset` validation? **Default:** `false`
2055+
* `noAssert` {boolean} Skip `value` and `offset` validation? **Default:** `false`
20152056
* Returns: {Integer} `offset` plus the number of bytes written
20162057

20172058
Writes `value` to `buf` at the specified `offset` with specified endian
@@ -2044,9 +2085,9 @@ console.log(buf);
20442085
added: v0.11.15
20452086
-->
20462087

2047-
* `value` {Number} Number to be written to `buf`
2088+
* `value` {number} Number to be written to `buf`
20482089
* `offset` {Integer} Where to start writing. Must satisfy: `0 <= offset <= buf.length - 4`
2049-
* `noAssert` {Boolean} Skip `value` and `offset` validation? **Default:** `false`
2090+
* `noAssert` {boolean} Skip `value` and `offset` validation? **Default:** `false`
20502091
* Returns: {Integer} `offset` plus the number of bytes written
20512092

20522093
Writes `value` to `buf` at the specified `offset` with specified endian
@@ -2080,7 +2121,7 @@ added: v0.5.0
20802121

20812122
* `value` {Integer} Number to be written to `buf`
20822123
* `offset` {Integer} Where to start writing. Must satisfy: `0 <= offset <= buf.length - 1`
2083-
* `noAssert` {Boolean} Skip `value` and `offset` validation? **Default:** `false`
2124+
* `noAssert` {boolean} Skip `value` and `offset` validation? **Default:** `false`
20842125
* Returns: {Integer} `offset` plus the number of bytes written
20852126

20862127
Writes `value` to `buf` at the specified `offset`. `value` *should* be a valid
@@ -2112,7 +2153,7 @@ added: v0.5.5
21122153

21132154
* `value` {Integer} Number to be written to `buf`
21142155
* `offset` {Integer} Where to start writing. Must satisfy: `0 <= offset <= buf.length - 2`
2115-
* `noAssert` {Boolean} Skip `value` and `offset` validation? **Default:** `false`
2156+
* `noAssert` {boolean} Skip `value` and `offset` validation? **Default:** `false`
21162157
* Returns: {Integer} `offset` plus the number of bytes written
21172158

21182159
Writes `value` to `buf` at the specified `offset` with specified endian
@@ -2145,7 +2186,7 @@ added: v0.5.5
21452186

21462187
* `value` {Integer} Number to be written to `buf`
21472188
* `offset` {Integer} Where to start writing. Must satisfy: `0 <= offset <= buf.length - 4`
2148-
* `noAssert` {Boolean} Skip `value` and `offset` validation? **Default:** `false`
2189+
* `noAssert` {boolean} Skip `value` and `offset` validation? **Default:** `false`
21492190
* Returns: {Integer} `offset` plus the number of bytes written
21502191

21512192
Writes `value` to `buf` at the specified `offset` with specified endian
@@ -2179,7 +2220,7 @@ added: v0.11.15
21792220
* `value` {Integer} Number to be written to `buf`
21802221
* `offset` {Integer} Where to start writing. Must satisfy: `0 <= offset <= buf.length - byteLength`
21812222
* `byteLength` {Integer} How many bytes to write. Must satisfy: `0 < byteLength <= 6`
2182-
* `noAssert` {Boolean} Skip `value`, `offset`, and `byteLength` validation?
2223+
* `noAssert` {boolean} Skip `value`, `offset`, and `byteLength` validation?
21832224
**Default:** `false`
21842225
* Returns: {Integer} `offset` plus the number of bytes written
21852226

@@ -2213,7 +2254,7 @@ added: v0.5.0
22132254

22142255
* `value` {Integer} Number to be written to `buf`
22152256
* `offset` {Integer} Where to start writing. Must satisfy: `0 <= offset <= buf.length - 1`
2216-
* `noAssert` {Boolean} Skip `value` and `offset` validation? **Default:** `false`
2257+
* `noAssert` {boolean} Skip `value` and `offset` validation? **Default:** `false`
22172258
* Returns: {Integer} `offset` plus the number of bytes written
22182259

22192260
Writes `value` to `buf` at the specified `offset`. `value` *should* be a
@@ -2245,7 +2286,7 @@ added: v0.5.5
22452286

22462287
* `value` {Integer} Number to be written to `buf`
22472288
* `offset` {Integer} Where to start writing. Must satisfy: `0 <= offset <= buf.length - 2`
2248-
* `noAssert` {Boolean} Skip `value` and `offset` validation? **Default:** `false`
2289+
* `noAssert` {boolean} Skip `value` and `offset` validation? **Default:** `false`
22492290
* Returns: {Integer} `offset` plus the number of bytes written
22502291

22512292
Writes `value` to `buf` at the specified `offset` with specified endian
@@ -2282,7 +2323,7 @@ added: v0.5.5
22822323

22832324
* `value` {Integer} Number to be written to `buf`
22842325
* `offset` {Integer} Where to start writing. Must satisfy: `0 <= offset <= buf.length - 4`
2285-
* `noAssert` {Boolean} Skip `value` and `offset` validation? **Default:** `false`
2326+
* `noAssert` {boolean} Skip `value` and `offset` validation? **Default:** `false`
22862327
* Returns: {Integer} `offset` plus the number of bytes written
22872328

22882329
Writes `value` to `buf` at the specified `offset` with specified endian
@@ -2318,7 +2359,7 @@ added: v0.5.5
23182359
* `value` {Integer} Number to be written to `buf`
23192360
* `offset` {Integer} Where to start writing. Must satisfy: `0 <= offset <= buf.length - byteLength`
23202361
* `byteLength` {Integer} How many bytes to write. Must satisfy: `0 < byteLength <= 6`
2321-
* `noAssert` {Boolean} Skip `value`, `offset`, and `byteLength` validation?
2362+
* `noAssert` {boolean} Skip `value`, `offset`, and `byteLength` validation?
23222363
**Default:** `false`
23232364
* Returns: {Integer} `offset` plus the number of bytes written
23242365

0 commit comments

Comments
 (0)