Skip to content

Commit 52b2536

Browse files
vsemozhetbytsam-github
authored andcommitted
doc: fix sorting in API references
PR-URL: #11331 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
1 parent dfa8abe commit 52b2536

12 files changed

+472
-472
lines changed

doc/api/buffer.md

+96-96
Original file line numberDiff line numberDiff line change
@@ -313,32 +313,6 @@ Example:
313313
const buf = new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
314314
```
315315

316-
### new Buffer(buffer)
317-
<!-- YAML
318-
deprecated: v6.0.0
319-
-->
320-
321-
> Stability: 0 - Deprecated: Use [`Buffer.from(buffer)`] instead.
322-
323-
* `buffer` {Buffer} An existing `Buffer` to copy data from
324-
325-
Copies the passed `buffer` data onto a new `Buffer` instance.
326-
327-
Example:
328-
329-
```js
330-
const buf1 = new Buffer('buffer');
331-
const buf2 = new Buffer(buf1);
332-
333-
buf1[0] = 0x61;
334-
335-
// Prints: auffer
336-
console.log(buf1.toString());
337-
338-
// Prints: buffer
339-
console.log(buf2.toString());
340-
```
341-
342316
### new Buffer(arrayBuffer[, byteOffset [, length]])
343317
<!-- YAML
344318
deprecated: v6.0.0
@@ -383,6 +357,32 @@ arr[1] = 6000;
383357
console.log(buf);
384358
```
385359

360+
### new Buffer(buffer)
361+
<!-- YAML
362+
deprecated: v6.0.0
363+
-->
364+
365+
> Stability: 0 - Deprecated: Use [`Buffer.from(buffer)`] instead.
366+
367+
* `buffer` {Buffer} An existing `Buffer` to copy data from
368+
369+
Copies the passed `buffer` data onto a new `Buffer` instance.
370+
371+
Example:
372+
373+
```js
374+
const buf1 = new Buffer('buffer');
375+
const buf2 = new Buffer(buf1);
376+
377+
buf1[0] = 0x61;
378+
379+
// Prints: auffer
380+
console.log(buf1.toString());
381+
382+
// Prints: buffer
383+
console.log(buf2.toString());
384+
```
385+
386386
### new Buffer(size)
387387
<!-- YAML
388388
deprecated: v6.0.0
@@ -1113,6 +1113,47 @@ Example: Fill a `Buffer` with a two-byte character
11131113
console.log(Buffer.allocUnsafe(3).fill('\u0222'));
11141114
```
11151115

1116+
### buf.includes(value[, byteOffset][, encoding])
1117+
<!-- YAML
1118+
added: v5.3.0
1119+
-->
1120+
1121+
* `value` {String | Buffer | Integer} What to search for
1122+
* `byteOffset` {Integer} Where to begin searching in `buf`. **Default:** `0`
1123+
* `encoding` {String} If `value` is a string, this is its encoding.
1124+
**Default:** `'utf8'`
1125+
* Returns: {Boolean} `true` if `value` was found in `buf`, `false` otherwise
1126+
1127+
Equivalent to [`buf.indexOf() !== -1`][`buf.indexOf()`].
1128+
1129+
Examples:
1130+
1131+
```js
1132+
const buf = Buffer.from('this is a buffer');
1133+
1134+
// Prints: true
1135+
console.log(buf.includes('this'));
1136+
1137+
// Prints: true
1138+
console.log(buf.includes('is'));
1139+
1140+
// Prints: true
1141+
console.log(buf.includes(Buffer.from('a buffer')));
1142+
1143+
// Prints: true
1144+
// (97 is the decimal ASCII value for 'a')
1145+
console.log(buf.includes(97));
1146+
1147+
// Prints: false
1148+
console.log(buf.includes(Buffer.from('a buffer example')));
1149+
1150+
// Prints: true
1151+
console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));
1152+
1153+
// Prints: false
1154+
console.log(buf.includes('this', 4));
1155+
```
1156+
11161157
### buf.indexOf(value[, byteOffset][, encoding])
11171158
<!-- YAML
11181159
added: v1.5.0
@@ -1192,47 +1233,6 @@ console.log(b.indexOf('b', null));
11921233
console.log(b.indexOf('b', []));
11931234
```
11941235

1195-
### buf.includes(value[, byteOffset][, encoding])
1196-
<!-- YAML
1197-
added: v5.3.0
1198-
-->
1199-
1200-
* `value` {String | Buffer | Integer} What to search for
1201-
* `byteOffset` {Integer} Where to begin searching in `buf`. **Default:** `0`
1202-
* `encoding` {String} If `value` is a string, this is its encoding.
1203-
**Default:** `'utf8'`
1204-
* Returns: {Boolean} `true` if `value` was found in `buf`, `false` otherwise
1205-
1206-
Equivalent to [`buf.indexOf() !== -1`][`buf.indexOf()`].
1207-
1208-
Examples:
1209-
1210-
```js
1211-
const buf = Buffer.from('this is a buffer');
1212-
1213-
// Prints: true
1214-
console.log(buf.includes('this'));
1215-
1216-
// Prints: true
1217-
console.log(buf.includes('is'));
1218-
1219-
// Prints: true
1220-
console.log(buf.includes(Buffer.from('a buffer')));
1221-
1222-
// Prints: true
1223-
// (97 is the decimal ASCII value for 'a')
1224-
console.log(buf.includes(97));
1225-
1226-
// Prints: false
1227-
console.log(buf.includes(Buffer.from('a buffer example')));
1228-
1229-
// Prints: true
1230-
console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));
1231-
1232-
// Prints: false
1233-
console.log(buf.includes('this', 4));
1234-
```
1235-
12361236
### buf.keys()
12371237
<!-- YAML
12381238
added: v1.1.0
@@ -1878,6 +1878,35 @@ buf2.swap64();
18781878
Note that JavaScript cannot encode 64-bit integers. This method is intended
18791879
for working with 64-bit floats.
18801880

1881+
### buf.toJSON()
1882+
<!-- YAML
1883+
added: v0.9.2
1884+
-->
1885+
1886+
* Returns: {Object}
1887+
1888+
Returns a JSON representation of `buf`. [`JSON.stringify()`] implicitly calls
1889+
this function when stringifying a `Buffer` instance.
1890+
1891+
Example:
1892+
1893+
```js
1894+
const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
1895+
const json = JSON.stringify(buf);
1896+
1897+
// Prints: {"type":"Buffer","data":[1,2,3,4,5]}
1898+
console.log(json);
1899+
1900+
const copy = JSON.parse(json, (key, value) => {
1901+
return value && value.type === 'Buffer'
1902+
? Buffer.from(value.data)
1903+
: value;
1904+
});
1905+
1906+
// Prints: <Buffer 01 02 03 04 05>
1907+
console.log(copy);
1908+
```
1909+
18811910
### buf.toString([encoding[, start[, end]]])
18821911
<!-- YAML
18831912
added: v0.1.90
@@ -1921,35 +1950,6 @@ console.log(buf2.toString('utf8', 0, 3));
19211950
console.log(buf2.toString(undefined, 0, 3));
19221951
```
19231952

1924-
### buf.toJSON()
1925-
<!-- YAML
1926-
added: v0.9.2
1927-
-->
1928-
1929-
* Returns: {Object}
1930-
1931-
Returns a JSON representation of `buf`. [`JSON.stringify()`] implicitly calls
1932-
this function when stringifying a `Buffer` instance.
1933-
1934-
Example:
1935-
1936-
```js
1937-
const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
1938-
const json = JSON.stringify(buf);
1939-
1940-
// Prints: {"type":"Buffer","data":[1,2,3,4,5]}
1941-
console.log(json);
1942-
1943-
const copy = JSON.parse(json, (key, value) => {
1944-
return value && value.type === 'Buffer'
1945-
? Buffer.from(value.data)
1946-
: value;
1947-
});
1948-
1949-
// Prints: <Buffer 01 02 03 04 05>
1950-
console.log(copy);
1951-
```
1952-
19531953
### buf.values()
19541954
<!-- YAML
19551955
added: v1.1.0

doc/api/crypto.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -1427,22 +1427,6 @@ keys:
14271427

14281428
All paddings are defined in `crypto.constants`.
14291429

1430-
### crypto.timingSafeEqual(a, b)
1431-
<!-- YAML
1432-
added: v6.6.0
1433-
-->
1434-
1435-
Returns true if `a` is equal to `b`, without leaking timing information that
1436-
would allow an attacker to guess one of the values. This is suitable for
1437-
comparing HMAC digests or secret values like authentication cookies or
1438-
[capability urls](https://www.w3.org/TR/capability-urls/).
1439-
1440-
`a` and `b` must both be `Buffer`s, and they must have the same length.
1441-
1442-
**Note**: Use of `crypto.timingSafeEqual` does not guarantee that the
1443-
*surrounding* code is timing-safe. Care should be taken to ensure that the
1444-
surrounding code does not introduce timing vulnerabilities.
1445-
14461430
### crypto.privateEncrypt(private_key, buffer)
14471431
<!-- YAML
14481432
added: v1.1.0
@@ -1576,6 +1560,22 @@ is a bit field taking one of or a mix of the following flags (defined in
15761560
* `crypto.constants.ENGINE_METHOD_ALL`
15771561
* `crypto.constants.ENGINE_METHOD_NONE`
15781562

1563+
### crypto.timingSafeEqual(a, b)
1564+
<!-- YAML
1565+
added: v6.6.0
1566+
-->
1567+
1568+
Returns true if `a` is equal to `b`, without leaking timing information that
1569+
would allow an attacker to guess one of the values. This is suitable for
1570+
comparing HMAC digests or secret values like authentication cookies or
1571+
[capability urls](https://www.w3.org/TR/capability-urls/).
1572+
1573+
`a` and `b` must both be `Buffer`s, and they must have the same length.
1574+
1575+
**Note**: Use of `crypto.timingSafeEqual` does not guarantee that the
1576+
*surrounding* code is timing-safe. Care should be taken to ensure that the
1577+
surrounding code does not introduce timing vulnerabilities.
1578+
15791579
## Notes
15801580

15811581
### Legacy Streams API (pre Node.js v0.10)

doc/api/dgram.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,22 @@ never have reason to call this.
225225
If `multicastInterface` is not specified, the operating system will attempt to
226226
drop membership on all valid interfaces.
227227

228+
### socket.ref()
229+
<!-- YAML
230+
added: v0.9.1
231+
-->
232+
233+
By default, binding a socket will cause it to block the Node.js process from
234+
exiting as long as the socket is open. The `socket.unref()` method can be used
235+
to exclude the socket from the reference counting that keeps the Node.js
236+
process active. The `socket.ref()` method adds the socket back to the reference
237+
counting and restores the default behavior.
238+
239+
Calling `socket.ref()` multiples times will have no additional effect.
240+
241+
The `socket.ref()` method returns a reference to the socket so calls can be
242+
chained.
243+
228244
### socket.send(msg, [offset, length,] port [, address] [, callback])
229245
<!-- YAML
230246
added: v0.1.99
@@ -379,22 +395,6 @@ Changing TTL values is typically done for network probes or when multicasting.
379395
The argument to `socket.setTTL()` is a number of hops between 1 and 255.
380396
The default on most systems is 64 but can vary.
381397

382-
### socket.ref()
383-
<!-- YAML
384-
added: v0.9.1
385-
-->
386-
387-
By default, binding a socket will cause it to block the Node.js process from
388-
exiting as long as the socket is open. The `socket.unref()` method can be used
389-
to exclude the socket from the reference counting that keeps the Node.js
390-
process active. The `socket.ref()` method adds the socket back to the reference
391-
counting and restores the default behavior.
392-
393-
Calling `socket.ref()` multiples times will have no additional effect.
394-
395-
The `socket.ref()` method returns a reference to the socket so calls can be
396-
chained.
397-
398398
### socket.unref()
399399
<!-- YAML
400400
added: v0.9.1

doc/api/dns.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,15 @@ Uses the DNS protocol to resolve name server records (`NS` records) for the
288288
contain an array of name server records available for `hostname`
289289
(e.g. `['ns1.example.com', 'ns2.example.com']`).
290290

291+
## dns.resolvePtr(hostname, callback)
292+
<!-- YAML
293+
added: v6.0.0
294+
-->
295+
296+
Uses the DNS protocol to resolve pointer records (`PTR` records) for the
297+
`hostname`. The `addresses` argument passed to the `callback` function will
298+
be an array of strings containing the reply records.
299+
291300
## dns.resolveSoa(hostname, callback)
292301
<!-- YAML
293302
added: v0.11.10
@@ -340,15 +349,6 @@ be an array of objects with the following properties:
340349
}
341350
```
342351

343-
## dns.resolvePtr(hostname, callback)
344-
<!-- YAML
345-
added: v6.0.0
346-
-->
347-
348-
Uses the DNS protocol to resolve pointer records (`PTR` records) for the
349-
`hostname`. The `addresses` argument passed to the `callback` function will
350-
be an array of strings containing the reply records.
351-
352352
## dns.resolveTxt(hostname, callback)
353353
<!-- YAML
354354
added: v0.1.27

0 commit comments

Comments
 (0)