Skip to content

Commit b01fd8c

Browse files
vsemozhetbytaddaleax
authored andcommitted
doc: fix sorting in API references
PR-URL: #11529 Backport-Of: #11331 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
1 parent 237db9c commit b01fd8c

File tree

12 files changed

+472
-472
lines changed

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
@@ -1100,6 +1100,47 @@ Example: Fill a `Buffer` with a two-byte character
11001100
console.log(Buffer.allocUnsafe(3).fill('\u0222'));
11011101
```
11021102

1103+
### buf.includes(value[, byteOffset][, encoding])
1104+
<!-- YAML
1105+
added: v5.3.0
1106+
-->
1107+
1108+
* `value` {String | Buffer | Integer} What to search for
1109+
* `byteOffset` {Integer} Where to begin searching in `buf`. **Default:** `0`
1110+
* `encoding` {String} If `value` is a string, this is its encoding.
1111+
**Default:** `'utf8'`
1112+
* Returns: {Boolean} `true` if `value` was found in `buf`, `false` otherwise
1113+
1114+
Equivalent to [`buf.indexOf() !== -1`][`buf.indexOf()`].
1115+
1116+
Examples:
1117+
1118+
```js
1119+
const buf = Buffer.from('this is a buffer');
1120+
1121+
// Prints: true
1122+
console.log(buf.includes('this'));
1123+
1124+
// Prints: true
1125+
console.log(buf.includes('is'));
1126+
1127+
// Prints: true
1128+
console.log(buf.includes(Buffer.from('a buffer')));
1129+
1130+
// Prints: true
1131+
// (97 is the decimal ASCII value for 'a')
1132+
console.log(buf.includes(97));
1133+
1134+
// Prints: false
1135+
console.log(buf.includes(Buffer.from('a buffer example')));
1136+
1137+
// Prints: true
1138+
console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));
1139+
1140+
// Prints: false
1141+
console.log(buf.includes('this', 4));
1142+
```
1143+
11031144
### buf.indexOf(value[, byteOffset][, encoding])
11041145
<!-- YAML
11051146
added: v1.5.0
@@ -1179,47 +1220,6 @@ console.log(b.indexOf('b', null));
11791220
console.log(b.indexOf('b', []));
11801221
```
11811222

1182-
### buf.includes(value[, byteOffset][, encoding])
1183-
<!-- YAML
1184-
added: v5.3.0
1185-
-->
1186-
1187-
* `value` {String | Buffer | Integer} What to search for
1188-
* `byteOffset` {Integer} Where to begin searching in `buf`. **Default:** `0`
1189-
* `encoding` {String} If `value` is a string, this is its encoding.
1190-
**Default:** `'utf8'`
1191-
* Returns: {Boolean} `true` if `value` was found in `buf`, `false` otherwise
1192-
1193-
Equivalent to [`buf.indexOf() !== -1`][`buf.indexOf()`].
1194-
1195-
Examples:
1196-
1197-
```js
1198-
const buf = Buffer.from('this is a buffer');
1199-
1200-
// Prints: true
1201-
console.log(buf.includes('this'));
1202-
1203-
// Prints: true
1204-
console.log(buf.includes('is'));
1205-
1206-
// Prints: true
1207-
console.log(buf.includes(Buffer.from('a buffer')));
1208-
1209-
// Prints: true
1210-
// (97 is the decimal ASCII value for 'a')
1211-
console.log(buf.includes(97));
1212-
1213-
// Prints: false
1214-
console.log(buf.includes(Buffer.from('a buffer example')));
1215-
1216-
// Prints: true
1217-
console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));
1218-
1219-
// Prints: false
1220-
console.log(buf.includes('this', 4));
1221-
```
1222-
12231223
### buf.keys()
12241224
<!-- YAML
12251225
added: v1.1.0
@@ -1859,6 +1859,35 @@ buf2.swap64();
18591859
Note that JavaScript cannot encode 64-bit integers. This method is intended
18601860
for working with 64-bit floats.
18611861

1862+
### buf.toJSON()
1863+
<!-- YAML
1864+
added: v0.9.2
1865+
-->
1866+
1867+
* Returns: {Object}
1868+
1869+
Returns a JSON representation of `buf`. [`JSON.stringify()`] implicitly calls
1870+
this function when stringifying a `Buffer` instance.
1871+
1872+
Example:
1873+
1874+
```js
1875+
const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
1876+
const json = JSON.stringify(buf);
1877+
1878+
// Prints: {"type":"Buffer","data":[1,2,3,4,5]}
1879+
console.log(json);
1880+
1881+
const copy = JSON.parse(json, (key, value) => {
1882+
return value && value.type === 'Buffer'
1883+
? Buffer.from(value.data)
1884+
: value;
1885+
});
1886+
1887+
// Prints: <Buffer 01 02 03 04 05>
1888+
console.log(copy);
1889+
```
1890+
18621891
### buf.toString([encoding[, start[, end]]])
18631892
<!-- YAML
18641893
added: v0.1.90
@@ -1902,35 +1931,6 @@ console.log(buf2.toString('utf8', 0, 3));
19021931
console.log(buf2.toString(undefined, 0, 3));
19031932
```
19041933

1905-
### buf.toJSON()
1906-
<!-- YAML
1907-
added: v0.9.2
1908-
-->
1909-
1910-
* Returns: {Object}
1911-
1912-
Returns a JSON representation of `buf`. [`JSON.stringify()`] implicitly calls
1913-
this function when stringifying a `Buffer` instance.
1914-
1915-
Example:
1916-
1917-
```js
1918-
const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
1919-
const json = JSON.stringify(buf);
1920-
1921-
// Prints: {"type":"Buffer","data":[1,2,3,4,5]}
1922-
console.log(json);
1923-
1924-
const copy = JSON.parse(json, (key, value) => {
1925-
return value && value.type === 'Buffer'
1926-
? Buffer.from(value.data)
1927-
: value;
1928-
});
1929-
1930-
// Prints: <Buffer 01 02 03 04 05>
1931-
console.log(copy);
1932-
```
1933-
19341934
### buf.values()
19351935
<!-- YAML
19361936
added: v1.1.0

doc/api/crypto.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -1478,22 +1478,6 @@ keys:
14781478

14791479
All paddings are defined in `crypto.constants`.
14801480

1481-
### crypto.timingSafeEqual(a, b)
1482-
<!-- YAML
1483-
added: v6.6.0
1484-
-->
1485-
1486-
Returns true if `a` is equal to `b`, without leaking timing information that
1487-
would allow an attacker to guess one of the values. This is suitable for
1488-
comparing HMAC digests or secret values like authentication cookies or
1489-
[capability urls](https://www.w3.org/TR/capability-urls/).
1490-
1491-
`a` and `b` must both be `Buffer`s, and they must have the same length.
1492-
1493-
**Note**: Use of `crypto.timingSafeEqual` does not guarantee that the
1494-
*surrounding* code is timing-safe. Care should be taken to ensure that the
1495-
surrounding code does not introduce timing vulnerabilities.
1496-
14971481
### crypto.privateEncrypt(private_key, buffer)
14981482
<!-- YAML
14991483
added: v1.1.0
@@ -1627,6 +1611,22 @@ is a bit field taking one of or a mix of the following flags (defined in
16271611
* `crypto.constants.ENGINE_METHOD_ALL`
16281612
* `crypto.constants.ENGINE_METHOD_NONE`
16291613

1614+
### crypto.timingSafeEqual(a, b)
1615+
<!-- YAML
1616+
added: v6.6.0
1617+
-->
1618+
1619+
Returns true if `a` is equal to `b`, without leaking timing information that
1620+
would allow an attacker to guess one of the values. This is suitable for
1621+
comparing HMAC digests or secret values like authentication cookies or
1622+
[capability urls](https://www.w3.org/TR/capability-urls/).
1623+
1624+
`a` and `b` must both be `Buffer`s, and they must have the same length.
1625+
1626+
**Note**: Use of `crypto.timingSafeEqual` does not guarantee that the
1627+
*surrounding* code is timing-safe. Care should be taken to ensure that the
1628+
surrounding code does not introduce timing vulnerabilities.
1629+
16301630
## Notes
16311631

16321632
### 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
@@ -386,22 +402,6 @@ Changing TTL values is typically done for network probes or when multicasting.
386402
The argument to `socket.setTTL()` is a number of hops between 1 and 255.
387403
The default on most systems is 64 but can vary.
388404

389-
### socket.ref()
390-
<!-- YAML
391-
added: v0.9.1
392-
-->
393-
394-
By default, binding a socket will cause it to block the Node.js process from
395-
exiting as long as the socket is open. The `socket.unref()` method can be used
396-
to exclude the socket from the reference counting that keeps the Node.js
397-
process active. The `socket.ref()` method adds the socket back to the reference
398-
counting and restores the default behavior.
399-
400-
Calling `socket.ref()` multiples times will have no additional effect.
401-
402-
The `socket.ref()` method returns a reference to the socket so calls can be
403-
chained.
404-
405405
### socket.unref()
406406
<!-- YAML
407407
added: v0.9.1

doc/api/dns.md

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

305+
## dns.resolvePtr(hostname, callback)
306+
<!-- YAML
307+
added: v6.0.0
308+
-->
309+
310+
Uses the DNS protocol to resolve pointer records (`PTR` records) for the
311+
`hostname`. The `addresses` argument passed to the `callback` function will
312+
be an array of strings containing the reply records.
313+
305314
## dns.resolveSoa(hostname, callback)
306315
<!-- YAML
307316
added: v0.11.10
@@ -354,15 +363,6 @@ be an array of objects with the following properties:
354363
}
355364
```
356365

357-
## dns.resolvePtr(hostname, callback)
358-
<!-- YAML
359-
added: v6.0.0
360-
-->
361-
362-
Uses the DNS protocol to resolve pointer records (`PTR` records) for the
363-
`hostname`. The `addresses` argument passed to the `callback` function will
364-
be an array of strings containing the reply records.
365-
366366
## dns.resolveTxt(hostname, callback)
367367
<!-- YAML
368368
added: v0.1.27

0 commit comments

Comments
 (0)