@node-red/editor-client 3.0.2 → 3.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/locales/de/editor.json +2 -0
  2. package/locales/de/infotips.json +0 -0
  3. package/locales/de/jsonata.json +0 -0
  4. package/locales/en-US/editor.json +37 -6
  5. package/locales/en-US/infotips.json +0 -0
  6. package/locales/en-US/jsonata.json +0 -0
  7. package/locales/fr/editor.json +1238 -0
  8. package/locales/fr/infotips.json +23 -0
  9. package/locales/fr/jsonata.json +274 -0
  10. package/locales/ja/editor.json +48 -9
  11. package/locales/ko/editor.json +233 -31
  12. package/locales/ko/infotips.json +0 -0
  13. package/locales/ko/jsonata.json +0 -0
  14. package/locales/pt-BR/editor.json +1208 -0
  15. package/locales/pt-BR/infotips.json +23 -0
  16. package/locales/pt-BR/jsonata.json +274 -0
  17. package/locales/ru/editor.json +2 -0
  18. package/locales/ru/infotips.json +0 -0
  19. package/locales/ru/jsonata.json +0 -0
  20. package/locales/zh-CN/editor.json +1175 -1049
  21. package/locales/zh-TW/editor.json +3 -0
  22. package/package.json +1 -1
  23. package/public/red/about +140 -0
  24. package/public/red/red.js +2699 -1397
  25. package/public/red/red.min.js +4 -3
  26. package/public/red/style.min.css +1 -1
  27. package/public/red/tours/3.0/images/context-menu.png +0 -0
  28. package/public/red/tours/3.0/welcome.js +155 -0
  29. package/public/red/tours/images/context-menu.png +0 -0
  30. package/public/red/tours/images/global-env-vars.png +0 -0
  31. package/public/red/tours/images/hiding-flows.png +0 -0
  32. package/public/red/tours/images/locking-flows.png +0 -0
  33. package/public/red/tours/images/mermaid.png +0 -0
  34. package/public/red/tours/images/node-help.png +0 -0
  35. package/public/red/tours/images/tab-changes.png +0 -0
  36. package/public/red/tours/welcome.js +111 -94
  37. package/public/types/node/assert/strict.d.ts +11 -0
  38. package/public/types/node/assert.d.ts +898 -64
  39. package/public/types/node/async_hooks.d.ts +362 -94
  40. package/public/types/node/buffer.d.ts +2158 -14
  41. package/public/types/node/child_process.d.ts +1109 -257
  42. package/public/types/node/cluster.d.ts +349 -200
  43. package/public/types/node/console.d.ts +313 -43
  44. package/public/types/node/crypto.d.ts +3329 -656
  45. package/public/types/node/dgram.d.ts +459 -58
  46. package/public/types/node/diagnostics_channel.d.ts +155 -0
  47. package/public/types/node/dns/promises.d.ts +371 -0
  48. package/public/types/node/dns.d.ts +532 -265
  49. package/public/types/node/domain.d.ts +159 -16
  50. package/public/types/node/events.d.ts +589 -30
  51. package/public/types/node/fs/promises.d.ts +1097 -0
  52. package/public/types/node/fs.d.ts +2484 -958
  53. package/public/types/node/globals.d.ts +43 -503
  54. package/public/types/node/http.d.ts +1156 -145
  55. package/public/types/node/http2.d.ts +1610 -470
  56. package/public/types/node/https.d.ts +462 -72
  57. package/public/types/node/module.d.ts +72 -13
  58. package/public/types/node/net.d.ts +663 -131
  59. package/public/types/node/os.d.ts +238 -25
  60. package/public/types/node/path.d.ts +57 -23
  61. package/public/types/node/perf_hooks.d.ts +424 -112
  62. package/public/types/node/process.d.ts +1261 -193
  63. package/public/types/node/querystring.d.ts +107 -7
  64. package/public/types/node/readline.d.ts +443 -74
  65. package/public/types/node/stream/consumers.d.ts +15 -0
  66. package/public/types/node/stream/promises.d.ts +45 -0
  67. package/public/types/node/stream/web.d.ts +395 -0
  68. package/public/types/node/stream.d.ts +1081 -177
  69. package/public/types/node/string_decoder.d.ts +57 -0
  70. package/public/types/node/test.d.ts +193 -0
  71. package/public/types/node/timers/promises.d.ts +96 -0
  72. package/public/types/node/timers.d.ts +87 -12
  73. package/public/types/node/tls.d.ts +457 -222
  74. package/public/types/node/trace_events.d.ts +107 -10
  75. package/public/types/node/tty.d.ts +158 -23
  76. package/public/types/node/url.d.ts +734 -28
  77. package/public/types/node/util.d.ts +1542 -164
  78. package/public/types/node/v8.d.ts +261 -73
  79. package/public/types/node/vm.d.ts +384 -32
  80. package/public/types/node/wasi.d.ts +92 -23
  81. package/public/types/node/worker_threads.d.ts +531 -123
  82. package/public/types/node/zlib.d.ts +216 -63
  83. package/public/types/node-red/func.d.ts +3 -0
  84. package/public/vendor/jquery/css/base/images/ui-icons_444444_256x240.png +0 -0
  85. package/public/vendor/jquery/css/base/images/ui-icons_555555_256x240.png +0 -0
  86. package/public/vendor/jquery/css/base/images/ui-icons_777620_256x240.png +0 -0
  87. package/public/vendor/jquery/css/base/images/ui-icons_777777_256x240.png +0 -0
  88. package/public/vendor/jquery/css/base/images/ui-icons_cc0000_256x240.png +0 -0
  89. package/public/vendor/jquery/css/base/images/ui-icons_ffffff_256x240.png +0 -0
  90. package/public/vendor/jquery/css/base/jquery-ui.min.css +4 -4
  91. package/public/vendor/mermaid/mermaid.min.js +1284 -0
  92. package/public/vendor/monaco/dist/{ade705761eb7e702770d.ttf → 7064e66c3890a12c47b4.ttf} +0 -0
  93. package/public/vendor/monaco/dist/css.worker.js +1 -1
  94. package/public/vendor/monaco/dist/css.worker.js.LICENSE.txt +1 -1
  95. package/public/vendor/monaco/dist/editor.js +1 -1
  96. package/public/vendor/monaco/dist/editor.js.LICENSE.txt +5 -1
  97. package/public/vendor/monaco/dist/editor.worker.js +1 -1
  98. package/public/vendor/monaco/dist/html.worker.js +1 -1
  99. package/public/vendor/monaco/dist/html.worker.js.LICENSE.txt +1 -1
  100. package/public/vendor/monaco/dist/json.worker.js +1 -1
  101. package/public/vendor/monaco/dist/json.worker.js.LICENSE.txt +1 -1
  102. package/public/vendor/monaco/dist/locale/cs.js +319 -71
  103. package/public/vendor/monaco/dist/locale/de.js +323 -75
  104. package/public/vendor/monaco/dist/locale/es.js +318 -70
  105. package/public/vendor/monaco/dist/locale/fr.js +327 -79
  106. package/public/vendor/monaco/dist/locale/it.js +325 -77
  107. package/public/vendor/monaco/dist/locale/ja.js +337 -89
  108. package/public/vendor/monaco/dist/locale/ko.js +324 -76
  109. package/public/vendor/monaco/dist/locale/pl.js +322 -74
  110. package/public/vendor/monaco/dist/locale/pt-br.js +321 -73
  111. package/public/vendor/monaco/dist/locale/qps-ploc.js +1580 -1332
  112. package/public/vendor/monaco/dist/locale/ru.js +324 -76
  113. package/public/vendor/monaco/dist/locale/tr.js +326 -78
  114. package/public/vendor/monaco/dist/locale/zh-hans.js +328 -80
  115. package/public/vendor/monaco/dist/locale/zh-hant.js +321 -73
  116. package/public/vendor/monaco/dist/theme/forge.json +236 -0
  117. package/public/vendor/monaco/dist/theme/github-dark.json +348 -0
  118. package/public/vendor/monaco/dist/theme/github-light.json +348 -0
  119. package/public/vendor/monaco/dist/theme/nord.json +93 -0
  120. package/public/vendor/monaco/dist/ts.worker.js +1 -1
  121. package/public/vendor/monaco/dist/ts.worker.js.LICENSE.txt +14 -6
  122. package/public/vendor/vendor.js +9 -15
  123. /package/public/red/tours/{images → 3.0/images}/continuous-search.png +0 -0
  124. /package/public/red/tours/{images → 3.0/images}/debug-path-tooltip.png +0 -0
  125. /package/public/red/tours/{images → 3.0/images}/junction-quick-add.png +0 -0
  126. /package/public/red/tours/{images → 3.0/images}/junction-slice.gif +0 -0
  127. /package/public/red/tours/{images → 3.0/images}/split-wire-with-links.gif +0 -0
@@ -1,30 +1,37 @@
1
1
 
2
2
  /* NOTE: Do not edit directly! This file is generated using `npm run update-types` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
3
3
 
4
+ /**
5
+ * > Stability: 2 - Stable
6
+ *
7
+ * The `net` module provides an asynchronous network API for creating stream-based
8
+ * TCP or `IPC` servers ({@link createServer}) and clients
9
+ * ({@link createConnection}).
10
+ *
11
+ * It can be accessed using:
12
+ *
13
+ * ```js
14
+ * const net = require('net');
15
+ * ```
16
+ * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/net.js)
17
+ */
4
18
  declare module 'net' {
5
- import * as stream from 'stream';
6
- import EventEmitter = require('events');
7
- import * as dns from 'dns';
8
-
9
- type LookupFunction = (
10
- hostname: string,
11
- options: dns.LookupOneOptions,
12
- callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
13
- ) => void;
14
-
19
+ import * as stream from 'node:stream';
20
+ import { Abortable, EventEmitter } from 'node:events';
21
+ import * as dns from 'node:dns';
22
+ type LookupFunction = (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
15
23
  interface AddressInfo {
16
24
  address: string;
17
25
  family: string;
18
26
  port: number;
19
27
  }
20
-
21
28
  interface SocketConstructorOpts {
22
29
  fd?: number | undefined;
23
30
  allowHalfOpen?: boolean | undefined;
24
31
  readable?: boolean | undefined;
25
32
  writable?: boolean | undefined;
33
+ signal?: AbortSignal;
26
34
  }
27
-
28
35
  interface OnReadOpts {
29
36
  buffer: Uint8Array | (() => Uint8Array);
30
37
  /**
@@ -34,7 +41,6 @@ declare module 'net' {
34
41
  */
35
42
  callback(bytesWritten: number, buf: Uint8Array): boolean;
36
43
  }
37
-
38
44
  interface ConnectOpts {
39
45
  /**
40
46
  * If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
@@ -43,7 +49,6 @@ declare module 'net' {
43
49
  */
44
50
  onread?: OnReadOpts | undefined;
45
51
  }
46
-
47
52
  interface TcpSocketConnectOpts extends ConnectOpts {
48
53
  port: number;
49
54
  host?: string | undefined;
@@ -52,53 +57,269 @@ declare module 'net' {
52
57
  hints?: number | undefined;
53
58
  family?: number | undefined;
54
59
  lookup?: LookupFunction | undefined;
60
+ noDelay?: boolean | undefined;
61
+ keepAlive?: boolean | undefined;
62
+ keepAliveInitialDelay?: number | undefined;
55
63
  }
56
-
57
64
  interface IpcSocketConnectOpts extends ConnectOpts {
58
65
  path: string;
59
66
  }
60
-
61
67
  type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
62
-
68
+ type SocketReadyState = 'opening' | 'open' | 'readOnly' | 'writeOnly' | 'closed';
69
+ /**
70
+ * This class is an abstraction of a TCP socket or a streaming `IPC` endpoint
71
+ * (uses named pipes on Windows, and Unix domain sockets otherwise). It is also
72
+ * an `EventEmitter`.
73
+ *
74
+ * A `net.Socket` can be created by the user and used directly to interact with
75
+ * a server. For example, it is returned by {@link createConnection},
76
+ * so the user can use it to talk to the server.
77
+ *
78
+ * It can also be created by Node.js and passed to the user when a connection
79
+ * is received. For example, it is passed to the listeners of a `'connection'` event emitted on a {@link Server}, so the user can use
80
+ * it to interact with the client.
81
+ * @since v0.3.4
82
+ */
63
83
  class Socket extends stream.Duplex {
64
84
  constructor(options?: SocketConstructorOpts);
65
-
66
- // Extended base methods
85
+ /**
86
+ * Sends data on the socket. The second parameter specifies the encoding in the
87
+ * case of a string. It defaults to UTF8 encoding.
88
+ *
89
+ * Returns `true` if the entire data was flushed successfully to the kernel
90
+ * buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is again free.
91
+ *
92
+ * The optional `callback` parameter will be executed when the data is finally
93
+ * written out, which may not be immediately.
94
+ *
95
+ * See `Writable` stream `write()` method for more
96
+ * information.
97
+ * @since v0.1.90
98
+ * @param [encoding='utf8'] Only used when data is `string`.
99
+ */
67
100
  write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
68
101
  write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean;
69
-
102
+ /**
103
+ * Initiate a connection on a given socket.
104
+ *
105
+ * Possible signatures:
106
+ *
107
+ * * `socket.connect(options[, connectListener])`
108
+ * * `socket.connect(path[, connectListener])` for `IPC` connections.
109
+ * * `socket.connect(port[, host][, connectListener])` for TCP connections.
110
+ * * Returns: `net.Socket` The socket itself.
111
+ *
112
+ * This function is asynchronous. When the connection is established, the `'connect'` event will be emitted. If there is a problem connecting,
113
+ * instead of a `'connect'` event, an `'error'` event will be emitted with
114
+ * the error passed to the `'error'` listener.
115
+ * The last parameter `connectListener`, if supplied, will be added as a listener
116
+ * for the `'connect'` event **once**.
117
+ *
118
+ * This function should only be used for reconnecting a socket after`'close'` has been emitted or otherwise it may lead to undefined
119
+ * behavior.
120
+ */
70
121
  connect(options: SocketConnectOpts, connectionListener?: () => void): this;
71
122
  connect(port: number, host: string, connectionListener?: () => void): this;
72
123
  connect(port: number, connectionListener?: () => void): this;
73
124
  connect(path: string, connectionListener?: () => void): this;
74
-
125
+ /**
126
+ * Set the encoding for the socket as a `Readable Stream`. See `readable.setEncoding()` for more information.
127
+ * @since v0.1.90
128
+ * @return The socket itself.
129
+ */
75
130
  setEncoding(encoding?: BufferEncoding): this;
131
+ /**
132
+ * Pauses the reading of data. That is, `'data'` events will not be emitted.
133
+ * Useful to throttle back an upload.
134
+ * @return The socket itself.
135
+ */
76
136
  pause(): this;
137
+ /**
138
+ * Resumes reading after a call to `socket.pause()`.
139
+ * @return The socket itself.
140
+ */
77
141
  resume(): this;
142
+ /**
143
+ * Sets the socket to timeout after `timeout` milliseconds of inactivity on
144
+ * the socket. By default `net.Socket` do not have a timeout.
145
+ *
146
+ * When an idle timeout is triggered the socket will receive a `'timeout'` event but the connection will not be severed. The user must manually call `socket.end()` or `socket.destroy()` to
147
+ * end the connection.
148
+ *
149
+ * ```js
150
+ * socket.setTimeout(3000);
151
+ * socket.on('timeout', () => {
152
+ * console.log('socket timeout');
153
+ * socket.end();
154
+ * });
155
+ * ```
156
+ *
157
+ * If `timeout` is 0, then the existing idle timeout is disabled.
158
+ *
159
+ * The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event.
160
+ * @since v0.1.90
161
+ * @return The socket itself.
162
+ */
78
163
  setTimeout(timeout: number, callback?: () => void): this;
164
+ /**
165
+ * Enable/disable the use of Nagle's algorithm.
166
+ *
167
+ * When a TCP connection is created, it will have Nagle's algorithm enabled.
168
+ *
169
+ * Nagle's algorithm delays data before it is sent via the network. It attempts
170
+ * to optimize throughput at the expense of latency.
171
+ *
172
+ * Passing `true` for `noDelay` or not passing an argument will disable Nagle's
173
+ * algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's
174
+ * algorithm.
175
+ * @since v0.1.90
176
+ * @param [noDelay=true]
177
+ * @return The socket itself.
178
+ */
79
179
  setNoDelay(noDelay?: boolean): this;
180
+ /**
181
+ * Enable/disable keep-alive functionality, and optionally set the initial
182
+ * delay before the first keepalive probe is sent on an idle socket.
183
+ *
184
+ * Set `initialDelay` (in milliseconds) to set the delay between the last
185
+ * data packet received and the first keepalive probe. Setting `0` for`initialDelay` will leave the value unchanged from the default
186
+ * (or previous) setting.
187
+ *
188
+ * Enabling the keep-alive functionality will set the following socket options:
189
+ *
190
+ * * `SO_KEEPALIVE=1`
191
+ * * `TCP_KEEPIDLE=initialDelay`
192
+ * * `TCP_KEEPCNT=10`
193
+ * * `TCP_KEEPINTVL=1`
194
+ * @since v0.1.92
195
+ * @param [enable=false]
196
+ * @param [initialDelay=0]
197
+ * @return The socket itself.
198
+ */
80
199
  setKeepAlive(enable?: boolean, initialDelay?: number): this;
200
+ /**
201
+ * Returns the bound `address`, the address `family` name and `port` of the
202
+ * socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
203
+ * @since v0.1.90
204
+ */
81
205
  address(): AddressInfo | {};
206
+ /**
207
+ * Calling `unref()` on a socket will allow the program to exit if this is the only
208
+ * active socket in the event system. If the socket is already `unref`ed calling`unref()` again will have no effect.
209
+ * @since v0.9.1
210
+ * @return The socket itself.
211
+ */
82
212
  unref(): this;
213
+ /**
214
+ * Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will_not_ let the program exit if it's the only socket left (the default behavior).
215
+ * If the socket is `ref`ed calling `ref` again will have no effect.
216
+ * @since v0.9.1
217
+ * @return The socket itself.
218
+ */
83
219
  ref(): this;
84
-
85
- /** @deprecated since v14.6.0 - Use `writableLength` instead. */
220
+ /**
221
+ * This property shows the number of characters buffered for writing. The buffer
222
+ * may contain strings whose length after encoding is not yet known. So this number
223
+ * is only an approximation of the number of bytes in the buffer.
224
+ *
225
+ * `net.Socket` has the property that `socket.write()` always works. This is to
226
+ * help users get up and running quickly. The computer cannot always keep up
227
+ * with the amount of data that is written to a socket. The network connection
228
+ * simply might be too slow. Node.js will internally queue up the data written to a
229
+ * socket and send it out over the wire when it is possible.
230
+ *
231
+ * The consequence of this internal buffering is that memory may grow.
232
+ * Users who experience large or growing `bufferSize` should attempt to
233
+ * "throttle" the data flows in their program with `socket.pause()` and `socket.resume()`.
234
+ * @since v0.3.8
235
+ * @deprecated Since v14.6.0 - Use `writableLength` instead.
236
+ */
86
237
  readonly bufferSize: number;
238
+ /**
239
+ * The amount of received bytes.
240
+ * @since v0.5.3
241
+ */
87
242
  readonly bytesRead: number;
243
+ /**
244
+ * The amount of bytes sent.
245
+ * @since v0.5.3
246
+ */
88
247
  readonly bytesWritten: number;
248
+ /**
249
+ * If `true`,`socket.connect(options[, connectListener])` was
250
+ * called and has not yet finished. It will stay `true` until the socket becomes
251
+ * connected, then it is set to `false` and the `'connect'` event is emitted. Note
252
+ * that the `socket.connect(options[, connectListener])` callback is a listener for the `'connect'` event.
253
+ * @since v6.1.0
254
+ */
89
255
  readonly connecting: boolean;
256
+ /**
257
+ * See `writable.destroyed` for further details.
258
+ */
90
259
  readonly destroyed: boolean;
91
- readonly localAddress: string;
92
- readonly localPort: number;
260
+ /**
261
+ * The string representation of the local IP address the remote client is
262
+ * connecting on. For example, in a server listening on `'0.0.0.0'`, if a client
263
+ * connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`.
264
+ * @since v0.9.6
265
+ */
266
+ readonly localAddress?: string;
267
+ /**
268
+ * The numeric representation of the local port. For example, `80` or `21`.
269
+ * @since v0.9.6
270
+ */
271
+ readonly localPort?: number;
272
+ /**
273
+ * The string representation of the local IP family. `'IPv4'` or `'IPv6'`.
274
+ * @since v18.8.0, v16.18.0
275
+ */
276
+ readonly localFamily?: string;
277
+ /**
278
+ * This is `true` if the socket is not connected yet, either because `.connect()`
279
+ * has not yet been called or because it is still in the process of connecting (see `socket.connecting`).
280
+ * @since v10.16.0
281
+ */
282
+ readonly pending: boolean;
283
+ /**
284
+ * This property represents the state of the connection as a string.
285
+ * @see {https://nodejs.org/api/net.html#socketreadystate}
286
+ * @since v0.5.0
287
+ */
288
+ readonly readyState: SocketReadyState;
289
+ /**
290
+ * The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if
291
+ * the socket is destroyed (for example, if the client disconnected).
292
+ * @since v0.5.10
293
+ */
93
294
  readonly remoteAddress?: string | undefined;
295
+ /**
296
+ * The string representation of the remote IP family. `'IPv4'` or `'IPv6'`.
297
+ * @since v0.11.14
298
+ */
94
299
  readonly remoteFamily?: string | undefined;
300
+ /**
301
+ * The numeric representation of the remote port. For example, `80` or `21`.
302
+ * @since v0.5.10
303
+ */
95
304
  readonly remotePort?: number | undefined;
96
-
97
- // Extended base methods
98
- end(cb?: () => void): this;
99
- end(buffer: Uint8Array | string, cb?: () => void): this;
100
- end(str: Uint8Array | string, encoding?: BufferEncoding, cb?: () => void): this;
101
-
305
+ /**
306
+ * The socket timeout in milliseconds as set by socket.setTimeout(). It is undefined if a timeout has not been set.
307
+ * @since v10.7.0
308
+ */
309
+ readonly timeout?: number | undefined;
310
+ /**
311
+ * Half-closes the socket. i.e., it sends a FIN packet. It is possible the
312
+ * server will still send some data.
313
+ *
314
+ * See `writable.end()` for further details.
315
+ * @since v0.1.90
316
+ * @param [encoding='utf8'] Only used when data is `string`.
317
+ * @param callback Optional callback for when the socket is finished.
318
+ * @return The socket itself.
319
+ */
320
+ end(callback?: () => void): this;
321
+ end(buffer: Uint8Array | string, callback?: () => void): this;
322
+ end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
102
323
  /**
103
324
  * events.EventEmitter
104
325
  * 1. close
@@ -111,73 +332,67 @@ declare module 'net' {
111
332
  * 8. timeout
112
333
  */
113
334
  addListener(event: string, listener: (...args: any[]) => void): this;
114
- addListener(event: "close", listener: (had_error: boolean) => void): this;
115
- addListener(event: "connect", listener: () => void): this;
116
- addListener(event: "data", listener: (data: Buffer) => void): this;
117
- addListener(event: "drain", listener: () => void): this;
118
- addListener(event: "end", listener: () => void): this;
119
- addListener(event: "error", listener: (err: Error) => void): this;
120
- addListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
121
- addListener(event: "ready", listener: () => void): this;
122
- addListener(event: "timeout", listener: () => void): this;
123
-
335
+ addListener(event: 'close', listener: (hadError: boolean) => void): this;
336
+ addListener(event: 'connect', listener: () => void): this;
337
+ addListener(event: 'data', listener: (data: Buffer) => void): this;
338
+ addListener(event: 'drain', listener: () => void): this;
339
+ addListener(event: 'end', listener: () => void): this;
340
+ addListener(event: 'error', listener: (err: Error) => void): this;
341
+ addListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
342
+ addListener(event: 'ready', listener: () => void): this;
343
+ addListener(event: 'timeout', listener: () => void): this;
124
344
  emit(event: string | symbol, ...args: any[]): boolean;
125
- emit(event: "close", had_error: boolean): boolean;
126
- emit(event: "connect"): boolean;
127
- emit(event: "data", data: Buffer): boolean;
128
- emit(event: "drain"): boolean;
129
- emit(event: "end"): boolean;
130
- emit(event: "error", err: Error): boolean;
131
- emit(event: "lookup", err: Error, address: string, family: string | number, host: string): boolean;
132
- emit(event: "ready"): boolean;
133
- emit(event: "timeout"): boolean;
134
-
345
+ emit(event: 'close', hadError: boolean): boolean;
346
+ emit(event: 'connect'): boolean;
347
+ emit(event: 'data', data: Buffer): boolean;
348
+ emit(event: 'drain'): boolean;
349
+ emit(event: 'end'): boolean;
350
+ emit(event: 'error', err: Error): boolean;
351
+ emit(event: 'lookup', err: Error, address: string, family: string | number, host: string): boolean;
352
+ emit(event: 'ready'): boolean;
353
+ emit(event: 'timeout'): boolean;
135
354
  on(event: string, listener: (...args: any[]) => void): this;
136
- on(event: "close", listener: (had_error: boolean) => void): this;
137
- on(event: "connect", listener: () => void): this;
138
- on(event: "data", listener: (data: Buffer) => void): this;
139
- on(event: "drain", listener: () => void): this;
140
- on(event: "end", listener: () => void): this;
141
- on(event: "error", listener: (err: Error) => void): this;
142
- on(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
143
- on(event: "ready", listener: () => void): this;
144
- on(event: "timeout", listener: () => void): this;
145
-
355
+ on(event: 'close', listener: (hadError: boolean) => void): this;
356
+ on(event: 'connect', listener: () => void): this;
357
+ on(event: 'data', listener: (data: Buffer) => void): this;
358
+ on(event: 'drain', listener: () => void): this;
359
+ on(event: 'end', listener: () => void): this;
360
+ on(event: 'error', listener: (err: Error) => void): this;
361
+ on(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
362
+ on(event: 'ready', listener: () => void): this;
363
+ on(event: 'timeout', listener: () => void): this;
146
364
  once(event: string, listener: (...args: any[]) => void): this;
147
- once(event: "close", listener: (had_error: boolean) => void): this;
148
- once(event: "connect", listener: () => void): this;
149
- once(event: "data", listener: (data: Buffer) => void): this;
150
- once(event: "drain", listener: () => void): this;
151
- once(event: "end", listener: () => void): this;
152
- once(event: "error", listener: (err: Error) => void): this;
153
- once(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
154
- once(event: "ready", listener: () => void): this;
155
- once(event: "timeout", listener: () => void): this;
156
-
365
+ once(event: 'close', listener: (hadError: boolean) => void): this;
366
+ once(event: 'connect', listener: () => void): this;
367
+ once(event: 'data', listener: (data: Buffer) => void): this;
368
+ once(event: 'drain', listener: () => void): this;
369
+ once(event: 'end', listener: () => void): this;
370
+ once(event: 'error', listener: (err: Error) => void): this;
371
+ once(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
372
+ once(event: 'ready', listener: () => void): this;
373
+ once(event: 'timeout', listener: () => void): this;
157
374
  prependListener(event: string, listener: (...args: any[]) => void): this;
158
- prependListener(event: "close", listener: (had_error: boolean) => void): this;
159
- prependListener(event: "connect", listener: () => void): this;
160
- prependListener(event: "data", listener: (data: Buffer) => void): this;
161
- prependListener(event: "drain", listener: () => void): this;
162
- prependListener(event: "end", listener: () => void): this;
163
- prependListener(event: "error", listener: (err: Error) => void): this;
164
- prependListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
165
- prependListener(event: "ready", listener: () => void): this;
166
- prependListener(event: "timeout", listener: () => void): this;
167
-
375
+ prependListener(event: 'close', listener: (hadError: boolean) => void): this;
376
+ prependListener(event: 'connect', listener: () => void): this;
377
+ prependListener(event: 'data', listener: (data: Buffer) => void): this;
378
+ prependListener(event: 'drain', listener: () => void): this;
379
+ prependListener(event: 'end', listener: () => void): this;
380
+ prependListener(event: 'error', listener: (err: Error) => void): this;
381
+ prependListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
382
+ prependListener(event: 'ready', listener: () => void): this;
383
+ prependListener(event: 'timeout', listener: () => void): this;
168
384
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
169
- prependOnceListener(event: "close", listener: (had_error: boolean) => void): this;
170
- prependOnceListener(event: "connect", listener: () => void): this;
171
- prependOnceListener(event: "data", listener: (data: Buffer) => void): this;
172
- prependOnceListener(event: "drain", listener: () => void): this;
173
- prependOnceListener(event: "end", listener: () => void): this;
174
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
175
- prependOnceListener(event: "lookup", listener: (err: Error, address: string, family: string | number, host: string) => void): this;
176
- prependOnceListener(event: "ready", listener: () => void): this;
177
- prependOnceListener(event: "timeout", listener: () => void): this;
385
+ prependOnceListener(event: 'close', listener: (hadError: boolean) => void): this;
386
+ prependOnceListener(event: 'connect', listener: () => void): this;
387
+ prependOnceListener(event: 'data', listener: (data: Buffer) => void): this;
388
+ prependOnceListener(event: 'drain', listener: () => void): this;
389
+ prependOnceListener(event: 'end', listener: () => void): this;
390
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
391
+ prependOnceListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
392
+ prependOnceListener(event: 'ready', listener: () => void): this;
393
+ prependOnceListener(event: 'timeout', listener: () => void): this;
178
394
  }
179
-
180
- interface ListenOptions {
395
+ interface ListenOptions extends Abortable {
181
396
  port?: number | undefined;
182
397
  host?: string | undefined;
183
398
  backlog?: number | undefined;
@@ -190,26 +405,85 @@ declare module 'net' {
190
405
  */
191
406
  ipv6Only?: boolean | undefined;
192
407
  }
193
-
194
408
  interface ServerOpts {
195
409
  /**
196
410
  * Indicates whether half-opened TCP connections are allowed.
197
411
  * @default false
198
412
  */
199
413
  allowHalfOpen?: boolean | undefined;
200
-
201
414
  /**
202
415
  * Indicates whether the socket should be paused on incoming connections.
203
416
  * @default false
204
417
  */
205
418
  pauseOnConnect?: boolean | undefined;
419
+ /**
420
+ * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received.
421
+ * @default false
422
+ * @since v16.5.0
423
+ */
424
+ noDelay?: boolean | undefined;
425
+ /**
426
+ * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
427
+ * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
428
+ * @default false
429
+ * @since v16.5.0
430
+ */
431
+ keepAlive?: boolean | undefined;
432
+ /**
433
+ * If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket.
434
+ * @default 0
435
+ * @since v16.5.0
436
+ */
437
+ keepAliveInitialDelay?: number | undefined;
206
438
  }
207
-
208
- // https://github.com/nodejs/node/blob/master/lib/net.js
439
+ /**
440
+ * This class is used to create a TCP or `IPC` server.
441
+ * @since v0.1.90
442
+ */
209
443
  class Server extends EventEmitter {
210
444
  constructor(connectionListener?: (socket: Socket) => void);
211
445
  constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void);
212
-
446
+ /**
447
+ * Start a server listening for connections. A `net.Server` can be a TCP or
448
+ * an `IPC` server depending on what it listens to.
449
+ *
450
+ * Possible signatures:
451
+ *
452
+ * * `server.listen(handle[, backlog][, callback])`
453
+ * * `server.listen(options[, callback])`
454
+ * * `server.listen(path[, backlog][, callback])` for `IPC` servers
455
+ * * `server.listen([port[, host[, backlog]]][, callback])` for TCP servers
456
+ *
457
+ * This function is asynchronous. When the server starts listening, the `'listening'` event will be emitted. The last parameter `callback`will be added as a listener for the `'listening'`
458
+ * event.
459
+ *
460
+ * All `listen()` methods can take a `backlog` parameter to specify the maximum
461
+ * length of the queue of pending connections. The actual length will be determined
462
+ * by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn`on Linux. The default value of this parameter is 511 (not 512).
463
+ *
464
+ * All {@link Socket} are set to `SO_REUSEADDR` (see [`socket(7)`](https://man7.org/linux/man-pages/man7/socket.7.html) for
465
+ * details).
466
+ *
467
+ * The `server.listen()` method can be called again if and only if there was an
468
+ * error during the first `server.listen()` call or `server.close()` has been
469
+ * called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN` error will be thrown.
470
+ *
471
+ * One of the most common errors raised when listening is `EADDRINUSE`.
472
+ * This happens when another server is already listening on the requested`port`/`path`/`handle`. One way to handle this would be to retry
473
+ * after a certain amount of time:
474
+ *
475
+ * ```js
476
+ * server.on('error', (e) => {
477
+ * if (e.code === 'EADDRINUSE') {
478
+ * console.log('Address in use, retrying...');
479
+ * setTimeout(() => {
480
+ * server.close();
481
+ * server.listen(PORT, HOST);
482
+ * }, 1000);
483
+ * }
484
+ * });
485
+ * ```
486
+ */
213
487
  listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
214
488
  listen(port?: number, hostname?: string, listeningListener?: () => void): this;
215
489
  listen(port?: number, backlog?: number, listeningListener?: () => void): this;
@@ -219,15 +493,79 @@ declare module 'net' {
219
493
  listen(options: ListenOptions, listeningListener?: () => void): this;
220
494
  listen(handle: any, backlog?: number, listeningListener?: () => void): this;
221
495
  listen(handle: any, listeningListener?: () => void): this;
496
+ /**
497
+ * Stops the server from accepting new connections and keeps existing
498
+ * connections. This function is asynchronous, the server is finally closed
499
+ * when all connections are ended and the server emits a `'close'` event.
500
+ * The optional `callback` will be called once the `'close'` event occurs. Unlike
501
+ * that event, it will be called with an `Error` as its only argument if the server
502
+ * was not open when it was closed.
503
+ * @since v0.1.90
504
+ * @param callback Called when the server is closed.
505
+ */
222
506
  close(callback?: (err?: Error) => void): this;
507
+ /**
508
+ * Returns the bound `address`, the address `family` name, and `port` of the server
509
+ * as reported by the operating system if listening on an IP socket
510
+ * (useful to find which port was assigned when getting an OS-assigned address):`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
511
+ *
512
+ * For a server listening on a pipe or Unix domain socket, the name is returned
513
+ * as a string.
514
+ *
515
+ * ```js
516
+ * const server = net.createServer((socket) => {
517
+ * socket.end('goodbye\n');
518
+ * }).on('error', (err) => {
519
+ * // Handle errors here.
520
+ * throw err;
521
+ * });
522
+ *
523
+ * // Grab an arbitrary unused port.
524
+ * server.listen(() => {
525
+ * console.log('opened server on', server.address());
526
+ * });
527
+ * ```
528
+ *
529
+ * `server.address()` returns `null` before the `'listening'` event has been
530
+ * emitted or after calling `server.close()`.
531
+ * @since v0.1.90
532
+ */
223
533
  address(): AddressInfo | string | null;
534
+ /**
535
+ * Asynchronously get the number of concurrent connections on the server. Works
536
+ * when sockets were sent to forks.
537
+ *
538
+ * Callback should take two arguments `err` and `count`.
539
+ * @since v0.9.7
540
+ */
224
541
  getConnections(cb: (error: Error | null, count: number) => void): void;
542
+ /**
543
+ * Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will_not_ let the program exit if it's the only server left (the default behavior).
544
+ * If the server is `ref`ed calling `ref()` again will have no effect.
545
+ * @since v0.9.1
546
+ */
225
547
  ref(): this;
548
+ /**
549
+ * Calling `unref()` on a server will allow the program to exit if this is the only
550
+ * active server in the event system. If the server is already `unref`ed calling`unref()` again will have no effect.
551
+ * @since v0.9.1
552
+ */
226
553
  unref(): this;
554
+ /**
555
+ * Set this property to reject connections when the server's connection count gets
556
+ * high.
557
+ *
558
+ * It is not recommended to use this option once a socket has been sent to a child
559
+ * with `child_process.fork()`.
560
+ * @since v0.2.0
561
+ */
227
562
  maxConnections: number;
228
563
  connections: number;
564
+ /**
565
+ * Indicates whether or not the server is listening for connections.
566
+ * @since v5.7.0
567
+ */
229
568
  listening: boolean;
230
-
231
569
  /**
232
570
  * events.EventEmitter
233
571
  * 1. close
@@ -236,63 +574,257 @@ declare module 'net' {
236
574
  * 4. listening
237
575
  */
238
576
  addListener(event: string, listener: (...args: any[]) => void): this;
239
- addListener(event: "close", listener: () => void): this;
240
- addListener(event: "connection", listener: (socket: Socket) => void): this;
241
- addListener(event: "error", listener: (err: Error) => void): this;
242
- addListener(event: "listening", listener: () => void): this;
243
-
577
+ addListener(event: 'close', listener: () => void): this;
578
+ addListener(event: 'connection', listener: (socket: Socket) => void): this;
579
+ addListener(event: 'error', listener: (err: Error) => void): this;
580
+ addListener(event: 'listening', listener: () => void): this;
244
581
  emit(event: string | symbol, ...args: any[]): boolean;
245
- emit(event: "close"): boolean;
246
- emit(event: "connection", socket: Socket): boolean;
247
- emit(event: "error", err: Error): boolean;
248
- emit(event: "listening"): boolean;
249
-
582
+ emit(event: 'close'): boolean;
583
+ emit(event: 'connection', socket: Socket): boolean;
584
+ emit(event: 'error', err: Error): boolean;
585
+ emit(event: 'listening'): boolean;
250
586
  on(event: string, listener: (...args: any[]) => void): this;
251
- on(event: "close", listener: () => void): this;
252
- on(event: "connection", listener: (socket: Socket) => void): this;
253
- on(event: "error", listener: (err: Error) => void): this;
254
- on(event: "listening", listener: () => void): this;
255
-
587
+ on(event: 'close', listener: () => void): this;
588
+ on(event: 'connection', listener: (socket: Socket) => void): this;
589
+ on(event: 'error', listener: (err: Error) => void): this;
590
+ on(event: 'listening', listener: () => void): this;
256
591
  once(event: string, listener: (...args: any[]) => void): this;
257
- once(event: "close", listener: () => void): this;
258
- once(event: "connection", listener: (socket: Socket) => void): this;
259
- once(event: "error", listener: (err: Error) => void): this;
260
- once(event: "listening", listener: () => void): this;
261
-
592
+ once(event: 'close', listener: () => void): this;
593
+ once(event: 'connection', listener: (socket: Socket) => void): this;
594
+ once(event: 'error', listener: (err: Error) => void): this;
595
+ once(event: 'listening', listener: () => void): this;
262
596
  prependListener(event: string, listener: (...args: any[]) => void): this;
263
- prependListener(event: "close", listener: () => void): this;
264
- prependListener(event: "connection", listener: (socket: Socket) => void): this;
265
- prependListener(event: "error", listener: (err: Error) => void): this;
266
- prependListener(event: "listening", listener: () => void): this;
267
-
597
+ prependListener(event: 'close', listener: () => void): this;
598
+ prependListener(event: 'connection', listener: (socket: Socket) => void): this;
599
+ prependListener(event: 'error', listener: (err: Error) => void): this;
600
+ prependListener(event: 'listening', listener: () => void): this;
268
601
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
269
- prependOnceListener(event: "close", listener: () => void): this;
270
- prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
271
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
272
- prependOnceListener(event: "listening", listener: () => void): this;
602
+ prependOnceListener(event: 'close', listener: () => void): this;
603
+ prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
604
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
605
+ prependOnceListener(event: 'listening', listener: () => void): this;
606
+ }
607
+ type IPVersion = 'ipv4' | 'ipv6';
608
+ /**
609
+ * The `BlockList` object can be used with some network APIs to specify rules for
610
+ * disabling inbound or outbound access to specific IP addresses, IP ranges, or
611
+ * IP subnets.
612
+ * @since v15.0.0
613
+ */
614
+ class BlockList {
615
+ /**
616
+ * Adds a rule to block the given IP address.
617
+ * @since v15.0.0
618
+ * @param address An IPv4 or IPv6 address.
619
+ * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
620
+ */
621
+ addAddress(address: string, type?: IPVersion): void;
622
+ addAddress(address: SocketAddress): void;
623
+ /**
624
+ * Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive).
625
+ * @since v15.0.0
626
+ * @param start The starting IPv4 or IPv6 address in the range.
627
+ * @param end The ending IPv4 or IPv6 address in the range.
628
+ * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
629
+ */
630
+ addRange(start: string, end: string, type?: IPVersion): void;
631
+ addRange(start: SocketAddress, end: SocketAddress): void;
632
+ /**
633
+ * Adds a rule to block a range of IP addresses specified as a subnet mask.
634
+ * @since v15.0.0
635
+ * @param net The network IPv4 or IPv6 address.
636
+ * @param prefix The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`.
637
+ * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
638
+ */
639
+ addSubnet(net: SocketAddress, prefix: number): void;
640
+ addSubnet(net: string, prefix: number, type?: IPVersion): void;
641
+ /**
642
+ * Returns `true` if the given IP address matches any of the rules added to the`BlockList`.
643
+ *
644
+ * ```js
645
+ * const blockList = new net.BlockList();
646
+ * blockList.addAddress('123.123.123.123');
647
+ * blockList.addRange('10.0.0.1', '10.0.0.10');
648
+ * blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6');
649
+ *
650
+ * console.log(blockList.check('123.123.123.123')); // Prints: true
651
+ * console.log(blockList.check('10.0.0.3')); // Prints: true
652
+ * console.log(blockList.check('222.111.111.222')); // Prints: false
653
+ *
654
+ * // IPv6 notation for IPv4 addresses works:
655
+ * console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true
656
+ * console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true
657
+ * ```
658
+ * @since v15.0.0
659
+ * @param address The IP address to check
660
+ * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
661
+ */
662
+ check(address: SocketAddress): boolean;
663
+ check(address: string, type?: IPVersion): boolean;
273
664
  }
274
-
275
665
  interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
276
666
  timeout?: number | undefined;
277
667
  }
278
-
279
668
  interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
280
669
  timeout?: number | undefined;
281
670
  }
282
-
283
671
  type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
284
-
672
+ /**
673
+ * Creates a new TCP or `IPC` server.
674
+ *
675
+ * If `allowHalfOpen` is set to `true`, when the other end of the socket
676
+ * signals the end of transmission, the server will only send back the end of
677
+ * transmission when `socket.end()` is explicitly called. For example, in the
678
+ * context of TCP, when a FIN packed is received, a FIN packed is sent
679
+ * back only when `socket.end()` is explicitly called. Until then the
680
+ * connection is half-closed (non-readable but still writable). See `'end'` event and [RFC 1122](https://tools.ietf.org/html/rfc1122) (section 4.2.2.13) for more information.
681
+ *
682
+ * If `pauseOnConnect` is set to `true`, then the socket associated with each
683
+ * incoming connection will be paused, and no data will be read from its handle.
684
+ * This allows connections to be passed between processes without any data being
685
+ * read by the original process. To begin reading data from a paused socket, call `socket.resume()`.
686
+ *
687
+ * The server can be a TCP server or an `IPC` server, depending on what it `listen()` to.
688
+ *
689
+ * Here is an example of an TCP echo server which listens for connections
690
+ * on port 8124:
691
+ *
692
+ * ```js
693
+ * const net = require('net');
694
+ * const server = net.createServer((c) => {
695
+ * // 'connection' listener.
696
+ * console.log('client connected');
697
+ * c.on('end', () => {
698
+ * console.log('client disconnected');
699
+ * });
700
+ * c.write('hello\r\n');
701
+ * c.pipe(c);
702
+ * });
703
+ * server.on('error', (err) => {
704
+ * throw err;
705
+ * });
706
+ * server.listen(8124, () => {
707
+ * console.log('server bound');
708
+ * });
709
+ * ```
710
+ *
711
+ * Test this by using `telnet`:
712
+ *
713
+ * ```console
714
+ * $ telnet localhost 8124
715
+ * ```
716
+ *
717
+ * To listen on the socket `/tmp/echo.sock`:
718
+ *
719
+ * ```js
720
+ * server.listen('/tmp/echo.sock', () => {
721
+ * console.log('server bound');
722
+ * });
723
+ * ```
724
+ *
725
+ * Use `nc` to connect to a Unix domain socket server:
726
+ *
727
+ * ```console
728
+ * $ nc -U /tmp/echo.sock
729
+ * ```
730
+ * @since v0.5.0
731
+ * @param connectionListener Automatically set as a listener for the {@link 'connection'} event.
732
+ */
285
733
  function createServer(connectionListener?: (socket: Socket) => void): Server;
286
734
  function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server;
735
+ /**
736
+ * Aliases to {@link createConnection}.
737
+ *
738
+ * Possible signatures:
739
+ *
740
+ * * {@link connect}
741
+ * * {@link connect} for `IPC` connections.
742
+ * * {@link connect} for TCP connections.
743
+ */
287
744
  function connect(options: NetConnectOpts, connectionListener?: () => void): Socket;
288
745
  function connect(port: number, host?: string, connectionListener?: () => void): Socket;
289
746
  function connect(path: string, connectionListener?: () => void): Socket;
747
+ /**
748
+ * A factory function, which creates a new {@link Socket},
749
+ * immediately initiates connection with `socket.connect()`,
750
+ * then returns the `net.Socket` that starts the connection.
751
+ *
752
+ * When the connection is established, a `'connect'` event will be emitted
753
+ * on the returned socket. The last parameter `connectListener`, if supplied,
754
+ * will be added as a listener for the `'connect'` event **once**.
755
+ *
756
+ * Possible signatures:
757
+ *
758
+ * * {@link createConnection}
759
+ * * {@link createConnection} for `IPC` connections.
760
+ * * {@link createConnection} for TCP connections.
761
+ *
762
+ * The {@link connect} function is an alias to this function.
763
+ */
290
764
  function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
291
765
  function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
292
766
  function createConnection(path: string, connectionListener?: () => void): Socket;
767
+ /**
768
+ * Tests if input is an IP address. Returns `0` for invalid strings,
769
+ * returns `4` for IP version 4 addresses, and returns `6` for IP version 6
770
+ * addresses.
771
+ * @since v0.3.0
772
+ */
293
773
  function isIP(input: string): number;
774
+ /**
775
+ * Returns `true` if input is a version 4 IP address, otherwise returns `false`.
776
+ * @since v0.3.0
777
+ */
294
778
  function isIPv4(input: string): boolean;
779
+ /**
780
+ * Returns `true` if input is a version 6 IP address, otherwise returns `false`.
781
+ * @since v0.3.0
782
+ */
295
783
  function isIPv6(input: string): boolean;
784
+ interface SocketAddressInitOptions {
785
+ /**
786
+ * The network address as either an IPv4 or IPv6 string.
787
+ * @default 127.0.0.1
788
+ */
789
+ address?: string | undefined;
790
+ /**
791
+ * @default `'ipv4'`
792
+ */
793
+ family?: IPVersion | undefined;
794
+ /**
795
+ * An IPv6 flow-label used only if `family` is `'ipv6'`.
796
+ * @default 0
797
+ */
798
+ flowlabel?: number | undefined;
799
+ /**
800
+ * An IP port.
801
+ * @default 0
802
+ */
803
+ port?: number | undefined;
804
+ }
805
+ /**
806
+ * @since v15.14.0
807
+ */
808
+ class SocketAddress {
809
+ constructor(options: SocketAddressInitOptions);
810
+ /**
811
+ * @since v15.14.0
812
+ */
813
+ readonly address: string;
814
+ /**
815
+ * Either \`'ipv4'\` or \`'ipv6'\`.
816
+ * @since v15.14.0
817
+ */
818
+ readonly family: IPVersion;
819
+ /**
820
+ * @since v15.14.0
821
+ */
822
+ readonly port: number;
823
+ /**
824
+ * @since v15.14.0
825
+ */
826
+ readonly flowlabel: number;
827
+ }
296
828
  }
297
829
  declare module 'node:net' {
298
830
  export * from 'net';