Skip to content

Commit 31b5ed4

Browse files
vsemozhetbytjasnell
authored andcommitted
doc: add and unify even more return values
PR-URL: #19955 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 0be14de commit 31b5ed4

20 files changed

+180
-24
lines changed

doc/api/crypto.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,7 @@ deprecated: v0.11.13
14071407
> Stability: 0 - Deprecated: Use [`tls.createSecureContext()`][] instead.
14081408
14091409
- `details` {Object} Identical to [`tls.createSecureContext()`][].
1410+
- Returns: {tls.SecureContext}
14101411

14111412
The `crypto.createCredentials()` method is a deprecated function for creating
14121413
and returning a `tls.SecureContext`. It should not be used. Replace it with

doc/api/dgram.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ available interface, call `addMembership` multiple times, once per interface.
100100
added: v0.1.99
101101
-->
102102

103+
* Returns: {Object}
104+
103105
Returns an object containing the address information for a socket.
104106
For UDP sockets, this object will contain `address`, `family` and `port`
105107
properties.

doc/api/dns.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ callbacks will be called with an error with code `ECANCELLED`.
110110
added: v0.11.3
111111
-->
112112

113+
* Returns: {string[]}
114+
113115
Returns an array of IP address strings, formatted according to [rfc5952][],
114116
that are currently configured for DNS resolution. A string will include a port
115117
section if a custom port is used.

doc/api/events.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ added: v0.1.26
298298
-->
299299
- `eventName` {string|symbol}
300300
- `...args` {any}
301+
- Returns: {boolean}
301302

302303
Synchronously calls each of the listeners registered for the event named
303304
`eventName`, in the order they were registered, passing the supplied arguments
@@ -310,6 +311,8 @@ Returns `true` if the event had listeners, `false` otherwise.
310311
added: v6.0.0
311312
-->
312313

314+
- Returns: {Array}
315+
313316
Returns an array listing the events for which the emitter has registered
314317
listeners. The values in the array will be strings or Symbols.
315318

@@ -331,6 +334,8 @@ console.log(myEE.eventNames());
331334
added: v1.0.0
332335
-->
333336

337+
- Returns: {integer}
338+
334339
Returns the current max listener value for the `EventEmitter` which is either
335340
set by [`emitter.setMaxListeners(n)`][] or defaults to
336341
[`EventEmitter.defaultMaxListeners`][].
@@ -341,6 +346,7 @@ added: v3.2.0
341346
-->
342347

343348
* `eventName` {string|symbol} The name of the event being listened for
349+
* Returns: {integer}
344350

345351
Returns the number of listeners listening to the event named `eventName`.
346352

@@ -354,6 +360,7 @@ changes:
354360
original listeners instead of wrapper functions now.
355361
-->
356362
- `eventName` {string|symbol}
363+
- Returns: {Function[]}
357364

358365
Returns a copy of the array of listeners for the event named `eventName`.
359366

@@ -372,6 +379,7 @@ added: v0.1.101
372379

373380
* `eventName` {string|symbol} The name of the event.
374381
* `listener` {Function} The callback function
382+
* Returns: {EventEmitter}
375383

376384
Adds the `listener` function to the end of the listeners array for the
377385
event named `eventName`. No checks are made to see if the `listener` has
@@ -408,6 +416,7 @@ added: v0.3.0
408416

409417
* `eventName` {string|symbol} The name of the event.
410418
* `listener` {Function} The callback function
419+
* Returns: {EventEmitter}
411420

412421
Adds a **one-time** `listener` function for the event named `eventName`. The
413422
next time `eventName` is triggered, this listener is removed and then invoked.
@@ -441,6 +450,7 @@ added: v6.0.0
441450

442451
* `eventName` {string|symbol} The name of the event.
443452
* `listener` {Function} The callback function
453+
* Returns: {EventEmitter}
444454

445455
Adds the `listener` function to the *beginning* of the listeners array for the
446456
event named `eventName`. No checks are made to see if the `listener` has
@@ -463,6 +473,7 @@ added: v6.0.0
463473

464474
* `eventName` {string|symbol} The name of the event.
465475
* `listener` {Function} The callback function
476+
* Returns: {EventEmitter}
466477

467478
Adds a **one-time** `listener` function for the event named `eventName` to the
468479
*beginning* of the listeners array. The next time `eventName` is triggered, this
@@ -481,6 +492,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained.
481492
added: v0.1.26
482493
-->
483494
- `eventName` {string|symbol}
495+
- Returns: {EventEmitter}
484496

485497
Removes all listeners, or those of the specified `eventName`.
486498

@@ -496,6 +508,7 @@ added: v0.1.26
496508
-->
497509
- `eventName` {string|symbol}
498510
- `listener` {Function}
511+
- Returns: {EventEmitter}
499512

500513
Removes the specified `listener` from the listener array for the event named
501514
`eventName`.
@@ -564,6 +577,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained.
564577
added: v0.3.5
565578
-->
566579
- `n` {integer}
580+
- Returns: {EventEmitter}
567581

568582
By default EventEmitters will print a warning if more than `10` listeners are
569583
added for a particular event. This is a useful default that helps finding
@@ -579,6 +593,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained.
579593
added: v9.4.0
580594
-->
581595
- `eventName` {string|symbol}
596+
- Returns: {Function[]}
582597

583598
Returns a copy of the array of listeners for the event named `eventName`,
584599
including any wrappers (such as those created by `.once`).

doc/api/fs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,8 @@ Synchronous close(2). Returns `undefined`.
11541154

11551155
## fs.constants
11561156

1157+
* {Object}
1158+
11571159
Returns an object containing commonly used constants for file system
11581160
operations. The specific constants currently defined are described in
11591161
[FS Constants][].

doc/api/http.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,11 @@ added: v0.5.9
662662
* `timeout` {number} Milliseconds before a request times out.
663663
* `callback` {Function} Optional function to be called when a timeout occurs.
664664
Same as binding to the `timeout` event.
665+
* Returns: {http.ClientRequest}
665666

666667
Once a socket is assigned to this request and is connected
667668
[`socket.setTimeout()`][] will be called.
668669

669-
Returns `request`.
670-
671670
### request.socket
672671
<!-- YAML
673672
added: v0.3.0
@@ -706,6 +705,7 @@ added: v0.1.29
706705
* `chunk` {string|Buffer}
707706
* `encoding` {string}
708707
* `callback` {Function}
708+
* Returns: {boolean}
709709

710710
Sends a chunk of the body. By calling this method
711711
many times, a request body can be sent to a
@@ -928,6 +928,7 @@ added: v0.9.12
928928

929929
* `msecs` {number} **Default:** `120000` (2 minutes)
930930
* `callback` {Function}
931+
* Returns: {http.Server}
931932

932933
Sets the timeout value for sockets, and emits a `'timeout'` event on
933934
the Server object, passing the socket as an argument, if a timeout
@@ -940,8 +941,6 @@ By default, the Server's timeout value is 2 minutes, and sockets are
940941
destroyed automatically if they time out. However, if a callback is assigned
941942
to the Server's `'timeout'` event, timeouts must be handled explicitly.
942943

943-
Returns `server`.
944-
945944
### server.timeout
946945
<!-- YAML
947946
added: v0.9.12
@@ -1248,6 +1247,7 @@ added: v0.9.12
12481247

12491248
* `msecs` {number}
12501249
* `callback` {Function}
1250+
* Returns: {http.ServerResponse}
12511251

12521252
Sets the Socket's timeout value to `msecs`. If a callback is
12531253
provided, then it is added as a listener on the `'timeout'` event on
@@ -1258,8 +1258,6 @@ the server, then sockets are destroyed when they time out. If a handler is
12581258
assigned to the request, the response, or the server's `'timeout'` events,
12591259
timed out sockets must be handled explicitly.
12601260

1261-
Returns `response`.
1262-
12631261
### response.socket
12641262
<!-- YAML
12651263
added: v0.3.0
@@ -1579,11 +1577,10 @@ added: v0.5.9
15791577

15801578
* `msecs` {number}
15811579
* `callback` {Function}
1580+
* Returns: {http.IncomingMessage}
15821581

15831582
Calls `message.connection.setTimeout(msecs, callback)`.
15841583

1585-
Returns `message`.
1586-
15871584
### message.socket
15881585
<!-- YAML
15891586
added: v0.3.0

doc/api/http2.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2489,6 +2489,7 @@ added: v8.4.0
24892489

24902490
* `msecs` {number}
24912491
* `callback` {Function}
2492+
* Returns: {http2.Http2ServerRequest}
24922493

24932494
Sets the [`Http2Stream`]()'s timeout value to `msecs`. If a callback is
24942495
provided, then it is added as a listener on the `'timeout'` event on
@@ -2499,8 +2500,6 @@ the server, then [`Http2Stream`]()s are destroyed when they time out. If a
24992500
handler is assigned to the request, the response, or the server's `'timeout'`
25002501
events, timed out sockets must be handled explicitly.
25012502

2502-
Returns `request`.
2503-
25042503
#### request.socket
25052504
<!-- YAML
25062505
added: v8.4.0
@@ -2866,6 +2865,7 @@ added: v8.4.0
28662865

28672866
* `msecs` {number}
28682867
* `callback` {Function}
2868+
* Returns: {http2.Http2ServerResponse}
28692869

28702870
Sets the [`Http2Stream`]()'s timeout value to `msecs`. If a callback is
28712871
provided, then it is added as a listener on the `'timeout'` event on
@@ -2876,8 +2876,6 @@ the server, then [`Http2Stream`]()s are destroyed when they time out. If a
28762876
handler is assigned to the request, the response, or the server's `'timeout'`
28772877
events, timed out sockets must be handled explicitly.
28782878

2879-
Returns `response`.
2880-
28812879
#### response.socket
28822880
<!-- YAML
28832881
added: v8.4.0

doc/api/inspector.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Deactivate the inspector. Blocks until there are no active connections.
3434

3535
### inspector.url()
3636

37+
* Returns: {string|undefined}
38+
3739
Return the URL of the active inspector, or `undefined` if there is none.
3840

3941
## Class: inspector.Session

doc/api/net.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ Emitted when the server has been bound after calling [`server.listen()`][].
112112
added: v0.1.90
113113
-->
114114

115+
* Returns: {Object}
116+
115117
Returns the bound address, the address family name, and port of the server
116118
as reported by the operating system if listening on an IP socket.
117119
Useful to find which port was assigned when getting an OS-assigned address.
@@ -153,8 +155,6 @@ The optional `callback` will be called once the `'close'` event occurs. Unlike
153155
that event, it will be called with an Error as its only argument if the server
154156
was not open when it was closed.
155157

156-
Returns `server`.
157-
158158
### server.connections
159159
<!-- YAML
160160
added: v0.2.0
@@ -500,6 +500,8 @@ See also: [`socket.setTimeout()`][]
500500
added: v0.1.90
501501
-->
502502

503+
* Returns: {Object}
504+
503505
Returns the bound address, the address family name and port of the
504506
socket as reported by the operating system. Returns an object with
505507
three properties, e.g.
@@ -601,8 +603,6 @@ For [IPC][] connections, available `options` are:
601603
See [Identifying paths for IPC connections][]. If provided, the TCP-specific
602604
options above are ignored.
603605

604-
Returns `socket`.
605-
606606
#### socket.connect(path[, connectListener])
607607

608608
* `path` {string} Path the client should connect to. See
@@ -617,8 +617,6 @@ Alias to
617617
[`socket.connect(options[, connectListener])`][`socket.connect(options)`]
618618
called with `{ path: path }` as `options`.
619619

620-
Returns `socket`.
621-
622620
#### socket.connect(port[, host][, connectListener])
623621
<!-- YAML
624622
added: v0.1.90
@@ -636,8 +634,6 @@ Alias to
636634
[`socket.connect(options[, connectListener])`][`socket.connect(options)`]
637635
called with `{port: port, host: host}` as `options`.
638636

639-
Returns `socket`.
640-
641637
### socket.connecting
642638
<!-- YAML
643639
added: v6.1.0
@@ -829,6 +825,8 @@ active socket in the event system. If the socket is already `unref`d calling
829825
added: v0.1.90
830826
-->
831827

828+
* Returns: {boolean}
829+
832830
Sends data on the socket. The second parameter specifies the encoding in the
833831
case of a string — it defaults to UTF8 encoding.
834832

@@ -1068,24 +1066,29 @@ $ nc -U /tmp/echo.sock
10681066
added: v0.3.0
10691067
-->
10701068

1071-
Tests if input is an IP address. Returns 0 for invalid strings,
1072-
returns 4 for IP version 4 addresses, and returns 6 for IP version 6 addresses.
1069+
* Returns: {integer}
10731070

1071+
Tests if input is an IP address. Returns `0` for invalid strings,
1072+
returns `4` for IP version 4 addresses, and returns `6` for IP version 6
1073+
addresses.
10741074

10751075
## net.isIPv4(input)
10761076
<!-- YAML
10771077
added: v0.3.0
10781078
-->
10791079

1080-
Returns true if input is a version 4 IP address, otherwise returns false.
1080+
* Returns: {boolean}
10811081

1082+
Returns `true` if input is a version 4 IP address, otherwise returns `false`.
10821083

10831084
## net.isIPv6(input)
10841085
<!-- YAML
10851086
added: v0.3.0
10861087
-->
10871088

1088-
Returns true if input is a version 6 IP address, otherwise returns false.
1089+
* Returns: {boolean}
1090+
1091+
Returns `true` if input is a version 6 IP address, otherwise returns `false`.
10891092

10901093
[`'close'`]: #net_event_close
10911094
[`'connect'`]: #net_event_connect

doc/api/punycode.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ punycode.ucs2.encode([0x1D306]); // '\uD834\uDF06'
145145
added: v0.6.1
146146
-->
147147

148+
* {string}
149+
148150
Returns a string identifying the current [Punycode.js][] version number.
149151

150152
[Punycode.js]: https://mths.be/punycode

0 commit comments

Comments
 (0)