@types/node 16.11.39 → 18.11.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 (111) hide show
  1. {node v16.11 → node}/LICENSE +0 -0
  2. node v16.11/README.md → node/README.md +4 -4
  3. {node v16.11 → node}/assert/strict.d.ts +0 -0
  4. node v16.11/assert.d.ts → node/assert.d.ts +7 -8
  5. node v16.11/async_hooks.d.ts → node/async_hooks.d.ts +8 -4
  6. node/buffer.d.ts +2258 -0
  7. node v16.11/child_process.d.ts → node/child_process.d.ts +6 -3
  8. node v16.11/cluster.d.ts → node/cluster.d.ts +14 -18
  9. node v16.11/console.d.ts → node/console.d.ts +1 -1
  10. {node v16.11 → node}/constants.d.ts +0 -0
  11. node v16.11/crypto.d.ts → node/crypto.d.ts +679 -53
  12. node v16.11/dgram.d.ts → node/dgram.d.ts +3 -3
  13. node v16.11/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +2 -1
  14. node v16.11/dns/promises.d.ts → node/dns/promises.d.ts +10 -8
  15. node v16.11/dns.d.ts → node/dns.d.ts +16 -11
  16. node/dom-events.d.ts +126 -0
  17. node v16.11/domain.d.ts → node/domain.d.ts +3 -2
  18. node v16.11/events.d.ts → node/events.d.ts +65 -10
  19. node v16.11/fs/promises.d.ts → node/fs/promises.d.ts +86 -39
  20. node v16.11/fs.d.ts → node/fs.d.ts +149 -67
  21. node/globals.d.ts +300 -0
  22. {node v16.11 → node}/globals.global.d.ts +0 -0
  23. node v16.11/http.d.ts → node/http.d.ts +305 -77
  24. node v16.11/http2.d.ts → node/http2.d.ts +38 -5
  25. node v16.11/https.d.ts → node/https.d.ts +209 -59
  26. node v16.11/index.d.ts → node/index.d.ts +6 -3
  27. node v16.11/inspector.d.ts → node/inspector.d.ts +11 -15
  28. {node v16.11 → node}/module.d.ts +0 -0
  29. node v16.11/net.d.ts → node/net.d.ts +94 -21
  30. node v16.11/os.d.ts → node/os.d.ts +15 -4
  31. node v16.11/package.json → node/package.json +15 -8
  32. node v16.11/path.d.ts → node/path.d.ts +34 -23
  33. node v16.11/perf_hooks.d.ts → node/perf_hooks.d.ts +76 -8
  34. node v16.11/process.d.ts → node/process.d.ts +17 -16
  35. node v16.11/punycode.d.ts → node/punycode.d.ts +1 -1
  36. node v16.11/querystring.d.ts → node/querystring.d.ts +4 -4
  37. node/readline/promises.d.ts +143 -0
  38. node v16.11/readline.d.ts → node/readline.d.ts +140 -30
  39. node v16.11/repl.d.ts → node/repl.d.ts +2 -2
  40. node v16.11/stream/consumers.d.ts → node/stream/consumers.d.ts +2 -14
  41. {node v16.11 → node}/stream/promises.d.ts +0 -0
  42. node v16.11/stream/web.d.ts → node/stream/web.d.ts +3 -65
  43. node v16.11/stream.d.ts → node/stream.d.ts +97 -19
  44. node v16.11/string_decoder.d.ts → node/string_decoder.d.ts +1 -1
  45. node/test.d.ts +314 -0
  46. {node v16.11 → node}/timers/promises.d.ts +0 -0
  47. node v16.11/timers.d.ts → node/timers.d.ts +1 -1
  48. node v16.11/tls.d.ts → node/tls.d.ts +32 -23
  49. node v16.11/trace_events.d.ts → node/trace_events.d.ts +11 -1
  50. node/ts4.8/assert/strict.d.ts +8 -0
  51. node/ts4.8/assert.d.ts +911 -0
  52. node/ts4.8/async_hooks.d.ts +501 -0
  53. node v16.11/buffer.d.ts → node/ts4.8/buffer.d.ts +46 -19
  54. node/ts4.8/child_process.d.ts +1369 -0
  55. node/ts4.8/cluster.d.ts +410 -0
  56. node/ts4.8/console.d.ts +412 -0
  57. node/ts4.8/constants.d.ts +18 -0
  58. node/ts4.8/crypto.d.ts +3964 -0
  59. node/ts4.8/dgram.d.ts +545 -0
  60. node/ts4.8/diagnostics_channel.d.ts +153 -0
  61. node/ts4.8/dns/promises.d.ts +370 -0
  62. node/ts4.8/dns.d.ts +659 -0
  63. node/ts4.8/dom-events.d.ts +126 -0
  64. node/ts4.8/domain.d.ts +170 -0
  65. node/ts4.8/events.d.ts +678 -0
  66. node/ts4.8/fs/promises.d.ts +1138 -0
  67. node/ts4.8/fs.d.ts +3872 -0
  68. node v16.11/globals.d.ts → node/ts4.8/globals.d.ts +14 -4
  69. node/ts4.8/globals.global.d.ts +1 -0
  70. node/ts4.8/http.d.ts +1607 -0
  71. node/ts4.8/http2.d.ts +2134 -0
  72. node/ts4.8/https.d.ts +541 -0
  73. node/ts4.8/index.d.ts +88 -0
  74. node/ts4.8/inspector.d.ts +2741 -0
  75. node/ts4.8/module.d.ts +114 -0
  76. node/ts4.8/net.d.ts +869 -0
  77. node/ts4.8/os.d.ts +466 -0
  78. node/ts4.8/path.d.ts +191 -0
  79. node/ts4.8/perf_hooks.d.ts +625 -0
  80. node/ts4.8/process.d.ts +1482 -0
  81. node/ts4.8/punycode.d.ts +117 -0
  82. node/ts4.8/querystring.d.ts +131 -0
  83. node/ts4.8/readline/promises.d.ts +143 -0
  84. node/ts4.8/readline.d.ts +653 -0
  85. node/ts4.8/repl.d.ts +424 -0
  86. node/ts4.8/stream/consumers.d.ts +12 -0
  87. node/ts4.8/stream/promises.d.ts +42 -0
  88. node/ts4.8/stream/web.d.ts +330 -0
  89. node/ts4.8/stream.d.ts +1340 -0
  90. node/ts4.8/string_decoder.d.ts +67 -0
  91. node/ts4.8/test.d.ts +314 -0
  92. node/ts4.8/timers/promises.d.ts +68 -0
  93. node/ts4.8/timers.d.ts +94 -0
  94. node/ts4.8/tls.d.ts +1028 -0
  95. node/ts4.8/trace_events.d.ts +171 -0
  96. node v16.11/tty.d.ts → node/ts4.8/tty.d.ts +4 -2
  97. node v16.11/url.d.ts → node/ts4.8/url.d.ts +85 -39
  98. node v16.11/util.d.ts → node/ts4.8/util.d.ts +268 -12
  99. node v16.11/v8.d.ts → node/ts4.8/v8.d.ts +21 -3
  100. node v16.11/vm.d.ts → node/ts4.8/vm.d.ts +6 -4
  101. node v16.11/wasi.d.ts → node/ts4.8/wasi.d.ts +1 -1
  102. node v16.11/worker_threads.d.ts → node/ts4.8/worker_threads.d.ts +50 -10
  103. node v16.11/zlib.d.ts → node/ts4.8/zlib.d.ts +1 -1
  104. node/tty.d.ts +206 -0
  105. node/url.d.ts +897 -0
  106. node/util.d.ts +1850 -0
  107. node/v8.d.ts +396 -0
  108. node/vm.d.ts +509 -0
  109. node/wasi.d.ts +158 -0
  110. node/worker_threads.d.ts +689 -0
  111. node/zlib.d.ts +517 -0
@@ -14,12 +14,14 @@
14
14
  *
15
15
  * The `stream` module is useful for creating new types of stream instances. It is
16
16
  * usually not necessary to use the `stream` module to consume streams.
17
- * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/stream.js)
17
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/stream.js)
18
18
  */
19
19
  declare module 'stream' {
20
20
  import { EventEmitter, Abortable } from 'node:events';
21
+ import { Blob as NodeBlob } from "node:buffer";
21
22
  import * as streamPromises from 'node:stream/promises';
22
23
  import * as streamConsumers from 'node:stream/consumers';
24
+ import * as streamWeb from 'node:stream/web';
23
25
  class internal extends EventEmitter {
24
26
  pipe<T extends NodeJS.WritableStream>(
25
27
  destination: T,
@@ -52,11 +54,23 @@ declare module 'stream' {
52
54
  * A utility method for creating Readable Streams out of iterators.
53
55
  */
54
56
  static from(iterable: Iterable<any> | AsyncIterable<any>, options?: ReadableOptions): Readable;
57
+ /**
58
+ * A utility method for creating a `Readable` from a web `ReadableStream`.
59
+ * @since v17.0.0
60
+ * @experimental
61
+ */
62
+ static fromWeb(readableStream: streamWeb.ReadableStream, options?: Pick<ReadableOptions, 'encoding' | 'highWaterMark' | 'objectMode' | 'signal'>): Readable;
55
63
  /**
56
64
  * Returns whether the stream has been read from or cancelled.
57
65
  * @since v16.8.0
58
66
  */
59
67
  static isDisturbed(stream: Readable | NodeJS.ReadableStream): boolean;
68
+ /**
69
+ * A utility method for creating a web `ReadableStream` from a `Readable`.
70
+ * @since v17.0.0
71
+ * @experimental
72
+ */
73
+ static toWeb(streamReadable: Readable): streamWeb.ReadableStream;
60
74
  /**
61
75
  * Returns whether the stream was destroyed or errored before emitting `'end'`.
62
76
  * @since v16.8.0
@@ -71,7 +85,7 @@ declare module 'stream' {
71
85
  readable: boolean;
72
86
  /**
73
87
  * Returns whether `'data'` has been emitted.
74
- * @since v16.7.0
88
+ * @since v16.7.0, v14.18.0
75
89
  * @experimental
76
90
  */
77
91
  readonly readableDidRead: boolean;
@@ -110,16 +124,26 @@ declare module 'stream' {
110
124
  readonly readableObjectMode: boolean;
111
125
  /**
112
126
  * Is `true` after `readable.destroy()` has been called.
113
- * @since v8.0.0
127
+ * @since v18.0.0
114
128
  */
115
129
  destroyed: boolean;
130
+ /**
131
+ * Is true after 'close' has been emitted.
132
+ * @since v8.0.0
133
+ */
134
+ readonly closed: boolean;
135
+ /**
136
+ * Returns error if the stream has been destroyed with an error.
137
+ * @since v18.0.0
138
+ */
139
+ readonly errored: Error | null;
116
140
  constructor(opts?: ReadableOptions);
117
141
  _construct?(callback: (error?: Error | null) => void): void;
118
142
  _read(size: number): void;
119
143
  /**
120
- * The `readable.read()` method pulls some data out of the internal buffer and
121
- * returns it. If no data available to be read, `null` is returned. By default,
122
- * the data will be returned as a `Buffer` object unless an encoding has been
144
+ * The `readable.read()` method reads data out of the internal buffer and
145
+ * returns it. If no data is available to be read, `null` is returned. By default,
146
+ * the data is returned as a `Buffer` object unless an encoding has been
123
147
  * specified using the `readable.setEncoding()` method or the stream is operating
124
148
  * in object mode.
125
149
  *
@@ -334,7 +358,7 @@ declare module 'stream' {
334
358
  * let chunk;
335
359
  * while (null !== (chunk = stream.read())) {
336
360
  * const str = decoder.write(chunk);
337
- * if (str.match(/\n\n/)) {
361
+ * if (str.includes('\n\n')) {
338
362
  * // Found the header boundary.
339
363
  * const split = str.split(/\n\n/);
340
364
  * header += split.shift();
@@ -347,10 +371,10 @@ declare module 'stream' {
347
371
  * stream.unshift(buf);
348
372
  * // Now the body of the message can be read from the stream.
349
373
  * callback(null, header, stream);
350
- * } else {
351
- * // Still reading the header.
352
- * header += str;
374
+ * return;
353
375
  * }
376
+ * // Still reading the header.
377
+ * header += str;
354
378
  * }
355
379
  * }
356
380
  * }
@@ -496,6 +520,18 @@ declare module 'stream' {
496
520
  * @since v0.9.4
497
521
  */
498
522
  class Writable extends Stream implements NodeJS.WritableStream {
523
+ /**
524
+ * A utility method for creating a `Writable` from a web `WritableStream`.
525
+ * @since v17.0.0
526
+ * @experimental
527
+ */
528
+ static fromWeb(writableStream: streamWeb.WritableStream, options?: Pick<WritableOptions, 'decodeStrings' | 'highWaterMark' | 'objectMode' | 'signal'>): Writable;
529
+ /**
530
+ * A utility method for creating a web `WritableStream` from a `Writable`.
531
+ * @since v17.0.0
532
+ * @experimental
533
+ */
534
+ static toWeb(streamWritable: Writable): streamWeb.WritableStream;
499
535
  /**
500
536
  * Is `true` if it is safe to call `writable.write()`, which means
501
537
  * the stream has not been destroyed, errored or ended.
@@ -541,6 +577,21 @@ declare module 'stream' {
541
577
  * @since v8.0.0
542
578
  */
543
579
  destroyed: boolean;
580
+ /**
581
+ * Is true after 'close' has been emitted.
582
+ * @since v8.0.0
583
+ */
584
+ readonly closed: boolean;
585
+ /**
586
+ * Returns error if the stream has been destroyed with an error.
587
+ * @since v18.0.0
588
+ */
589
+ readonly errored: Error | null;
590
+ /**
591
+ * Is `true` if the stream's buffer has been full and stream will emit 'drain'.
592
+ * @since v15.2.0, v14.17.0
593
+ */
594
+ readonly writableNeedDrain: boolean;
544
595
  constructor(opts?: WritableOptions);
545
596
  _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
546
597
  _writev?(
@@ -567,7 +618,7 @@ declare module 'stream' {
567
618
  * While a stream is not draining, calls to `write()` will buffer `chunk`, and
568
619
  * return false. Once all currently buffered chunks are drained (accepted for
569
620
  * delivery by the operating system), the `'drain'` event will be emitted.
570
- * It is recommended that once `write()` returns false, no more chunks be written
621
+ * Once `write()` returns false, do not write more chunks
571
622
  * until the `'drain'` event is emitted. While calling `write()` on a stream that
572
623
  * is not draining is allowed, Node.js will buffer all written chunks until
573
624
  * maximum memory usage occurs, at which point it will abort unconditionally.
@@ -661,8 +712,8 @@ declare module 'stream' {
661
712
  * The `writable.uncork()` method flushes all data buffered since {@link cork} was called.
662
713
  *
663
714
  * When using `writable.cork()` and `writable.uncork()` to manage the buffering
664
- * of writes to a stream, it is recommended that calls to `writable.uncork()` be
665
- * deferred using `process.nextTick()`. Doing so allows batching of all`writable.write()` calls that occur within a given Node.js event loop phase.
715
+ * of writes to a stream, defer calls to `writable.uncork()` using`process.nextTick()`. Doing so allows batching of all`writable.write()` calls that occur within a given Node.js event
716
+ * loop phase.
666
717
  *
667
718
  * ```js
668
719
  * stream.cork();
@@ -807,6 +858,9 @@ declare module 'stream' {
807
858
  readonly writableLength: number;
808
859
  readonly writableObjectMode: boolean;
809
860
  readonly writableCorked: number;
861
+ readonly writableNeedDrain: boolean;
862
+ readonly closed: boolean;
863
+ readonly errored: Error | null;
810
864
  /**
811
865
  * If `false` then the stream will automatically end the writable side when the
812
866
  * readable side ends. Set initially by the `allowHalfOpen` constructor option,
@@ -839,7 +893,7 @@ declare module 'stream' {
839
893
  *
840
894
  * @since v16.8.0
841
895
  */
842
- static from(src: Stream | Blob | ArrayBuffer | string | Iterable<any> | AsyncIterable<any> | AsyncGeneratorFunction | Promise<any> | Object): Duplex;
896
+ static from(src: Stream | NodeBlob | ArrayBuffer | string | Iterable<any> | AsyncIterable<any> | AsyncGeneratorFunction | Promise<any> | Object): Duplex;
843
897
  _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
844
898
  _writev?(
845
899
  chunks: Array<{
@@ -1106,7 +1160,7 @@ declare module 'stream' {
1106
1160
  * async function run() {
1107
1161
  * await pipeline(
1108
1162
  * fs.createReadStream('lowercase.txt'),
1109
- * async function* (source, signal) {
1163
+ * async function* (source, { signal }) {
1110
1164
  * source.setEncoding('utf8'); // Work with strings rather than `Buffer`s.
1111
1165
  * for await (const chunk of source) {
1112
1166
  * yield await processChunk(chunk, { signal });
@@ -1130,7 +1184,7 @@ declare module 'stream' {
1130
1184
  *
1131
1185
  * async function run() {
1132
1186
  * await pipeline(
1133
- * async function * (signal) {
1187
+ * async function* ({ signal }) {
1134
1188
  * await someLongRunningfn({ signal });
1135
1189
  * yield 'asd';
1136
1190
  * },
@@ -1149,7 +1203,31 @@ declare module 'stream' {
1149
1203
  *
1150
1204
  * `stream.pipeline()` leaves dangling event listeners on the streams
1151
1205
  * after the `callback` has been invoked. In the case of reuse of streams after
1152
- * failure, this can cause event listener leaks and swallowed errors.
1206
+ * failure, this can cause event listener leaks and swallowed errors. If the last
1207
+ * stream is readable, dangling event listeners will be removed so that the last
1208
+ * stream can be consumed later.
1209
+ *
1210
+ * `stream.pipeline()` closes all the streams when an error is raised.
1211
+ * The `IncomingRequest` usage with `pipeline` could lead to an unexpected behavior
1212
+ * once it would destroy the socket without sending the expected response.
1213
+ * See the example below:
1214
+ *
1215
+ * ```js
1216
+ * const fs = require('fs');
1217
+ * const http = require('http');
1218
+ * const { pipeline } = require('stream');
1219
+ *
1220
+ * const server = http.createServer((req, res) => {
1221
+ * const fileStream = fs.createReadStream('./fileNotExist.txt');
1222
+ * pipeline(fileStream, res, (err) => {
1223
+ * if (err) {
1224
+ * console.log(err); // No such file
1225
+ * // this message can't be sent once `pipeline` already destroyed the socket
1226
+ * return res.end('error!!!');
1227
+ * }
1228
+ * });
1229
+ * });
1230
+ * ```
1153
1231
  * @since v10.0.0
1154
1232
  * @param callback Called when the pipeline is fully done.
1155
1233
  */
@@ -1241,13 +1319,13 @@ declare module 'stream' {
1241
1319
 
1242
1320
  /**
1243
1321
  * Returns whether the stream has encountered an error.
1244
- * @since v16.14.0
1322
+ * @since v17.3.0
1245
1323
  */
1246
1324
  function isErrored(stream: Readable | Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean;
1247
1325
 
1248
1326
  /**
1249
1327
  * Returns whether the stream is readable.
1250
- * @since v16.14.0
1328
+ * @since v17.4.0
1251
1329
  */
1252
1330
  function isReadable(stream: Readable | NodeJS.ReadableStream): boolean;
1253
1331
 
@@ -36,7 +36,7 @@
36
36
  * decoder.write(Buffer.from([0x82]));
37
37
  * console.log(decoder.end(Buffer.from([0xAC])));
38
38
  * ```
39
- * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/string_decoder.js)
39
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/string_decoder.js)
40
40
  */
41
41
  declare module 'string_decoder' {
42
42
  class StringDecoder {
node/test.d.ts ADDED
@@ -0,0 +1,314 @@
1
+ /**
2
+ * The `node:test` module provides a standalone testing module.
3
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/test.js)
4
+ */
5
+ declare module 'node:test' {
6
+ /**
7
+ * Programmatically start the test runner.
8
+ * @since v18.9.0
9
+ * @param options Configuration options for running tests.
10
+ * @returns A {@link TapStream} that emits events about the test execution.
11
+ */
12
+ function run(options?: RunOptions): TapStream;
13
+
14
+ /**
15
+ * The `test()` function is the value imported from the test module. Each invocation of this
16
+ * function results in the creation of a test point in the TAP output.
17
+ *
18
+ * The {@link TestContext} object passed to the fn argument can be used to perform actions
19
+ * related to the current test. Examples include skipping the test, adding additional TAP
20
+ * diagnostic information, or creating subtests.
21
+ *
22
+ * `test()` returns a {@link Promise} that resolves once the test completes. The return value
23
+ * can usually be discarded for top level tests. However, the return value from subtests should
24
+ * be used to prevent the parent test from finishing first and cancelling the subtest as shown
25
+ * in the following example.
26
+ *
27
+ * ```js
28
+ * test('top level test', async (t) => {
29
+ * // The setTimeout() in the following subtest would cause it to outlive its
30
+ * // parent test if 'await' is removed on the next line. Once the parent test
31
+ * // completes, it will cancel any outstanding subtests.
32
+ * await t.test('longer running subtest', async (t) => {
33
+ * return new Promise((resolve, reject) => {
34
+ * setTimeout(resolve, 1000);
35
+ * });
36
+ * });
37
+ * });
38
+ * ```
39
+ * @since v18.0.0
40
+ * @param name The name of the test, which is displayed when reporting test results.
41
+ * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
42
+ * @param options Configuration options for the test
43
+ * @param fn The function under test. The first argument to this function is a
44
+ * {@link TestContext} object. If the test uses callbacks, the callback function is
45
+ * passed as the second argument. Default: A no-op function.
46
+ * @returns A {@link Promise} resolved with `undefined` once the test completes.
47
+ */
48
+ function test(name?: string, fn?: TestFn): Promise<void>;
49
+ function test(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
50
+ function test(options?: TestOptions, fn?: TestFn): Promise<void>;
51
+ function test(fn?: TestFn): Promise<void>;
52
+
53
+ /**
54
+ * @since v18.6.0
55
+ * @param name The name of the suite, which is displayed when reporting suite results.
56
+ * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
57
+ * @param options Configuration options for the suite
58
+ * @param fn The function under suite. Default: A no-op function.
59
+ */
60
+ function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void;
61
+ function describe(name?: string, fn?: SuiteFn): void;
62
+ function describe(options?: TestOptions, fn?: SuiteFn): void;
63
+ function describe(fn?: SuiteFn): void;
64
+
65
+ /**
66
+ * @since v18.6.0
67
+ * @param name The name of the test, which is displayed when reporting test results.
68
+ * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
69
+ * @param options Configuration options for the test
70
+ * @param fn The function under test. If the test uses callbacks, the callback function is
71
+ * passed as the second argument. Default: A no-op function.
72
+ */
73
+ function it(name?: string, options?: TestOptions, fn?: ItFn): void;
74
+ function it(name?: string, fn?: ItFn): void;
75
+ function it(options?: TestOptions, fn?: ItFn): void;
76
+ function it(fn?: ItFn): void;
77
+
78
+ /**
79
+ * The type of a function under test. The first argument to this function is a
80
+ * {@link TestContext} object. If the test uses callbacks, the callback function is passed as
81
+ * the second argument.
82
+ */
83
+ type TestFn = (t: TestContext, done: (result?: any) => void) => any;
84
+
85
+ /**
86
+ * The type of a function under Suite.
87
+ * If the test uses callbacks, the callback function is passed as an argument
88
+ */
89
+ type SuiteFn = (done: (result?: any) => void) => void;
90
+
91
+ /**
92
+ * The type of a function under test.
93
+ * If the test uses callbacks, the callback function is passed as an argument
94
+ */
95
+ type ItFn = (done: (result?: any) => void) => any;
96
+
97
+ interface RunOptions {
98
+ /**
99
+ * @default false
100
+ */
101
+ concurrency?: number | boolean;
102
+
103
+ /**
104
+ * An array containing the list of files to run. If unspecified, the test runner execution model will be used.
105
+ */
106
+ files?: readonly string[];
107
+
108
+ /**
109
+ * Allows aborting an in-progress test.
110
+ * @default undefined
111
+ */
112
+ signal?: AbortSignal;
113
+
114
+ /**
115
+ * A number of milliseconds the test will fail after. If unspecified, subtests inherit this
116
+ * value from their parent.
117
+ * @default Infinity
118
+ */
119
+ timeout?: number;
120
+ }
121
+
122
+ /**
123
+ * A successful call of the run() method will return a new TapStream object, streaming a TAP output.
124
+ * TapStream will emit events in the order of the tests' definitions.
125
+ * @since v18.9.0
126
+ */
127
+ interface TapStream extends NodeJS.ReadableStream {
128
+ addListener(event: 'test:diagnostic', listener: (message: string) => void): this;
129
+ addListener(event: 'test:fail', listener: (data: TestFail) => void): this;
130
+ addListener(event: 'test:pass', listener: (data: TestPass) => void): this;
131
+ addListener(event: string, listener: (...args: any[]) => void): this;
132
+ emit(event: 'test:diagnostic', message: string): boolean;
133
+ emit(event: 'test:fail', data: TestFail): boolean;
134
+ emit(event: 'test:pass', data: TestPass): boolean;
135
+ emit(event: string | symbol, ...args: any[]): boolean;
136
+ on(event: 'test:diagnostic', listener: (message: string) => void): this;
137
+ on(event: 'test:fail', listener: (data: TestFail) => void): this;
138
+ on(event: 'test:pass', listener: (data: TestPass) => void): this;
139
+ on(event: string, listener: (...args: any[]) => void): this;
140
+ once(event: 'test:diagnostic', listener: (message: string) => void): this;
141
+ once(event: 'test:fail', listener: (data: TestFail) => void): this;
142
+ once(event: 'test:pass', listener: (data: TestPass) => void): this;
143
+ once(event: string, listener: (...args: any[]) => void): this;
144
+ prependListener(event: 'test:diagnostic', listener: (message: string) => void): this;
145
+ prependListener(event: 'test:fail', listener: (data: TestFail) => void): this;
146
+ prependListener(event: 'test:pass', listener: (data: TestPass) => void): this;
147
+ prependListener(event: string, listener: (...args: any[]) => void): this;
148
+ prependOnceListener(event: 'test:diagnostic', listener: (message: string) => void): this;
149
+ prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this;
150
+ prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this;
151
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
152
+ }
153
+
154
+ interface TestFail {
155
+ /**
156
+ * The test duration.
157
+ */
158
+ duration: number;
159
+
160
+ /**
161
+ * The failure casing test to fail.
162
+ */
163
+ error: Error;
164
+
165
+ /**
166
+ * The test name.
167
+ */
168
+ name: string;
169
+
170
+ /**
171
+ * The ordinal number of the test.
172
+ */
173
+ testNumber: number;
174
+
175
+ /**
176
+ * Present if `context.todo` is called.
177
+ */
178
+ todo?: string;
179
+
180
+ /**
181
+ * Present if `context.skip` is called.
182
+ */
183
+ skip?: string;
184
+ }
185
+
186
+ interface TestPass {
187
+ /**
188
+ * The test duration.
189
+ */
190
+ duration: number;
191
+
192
+ /**
193
+ * The test name.
194
+ */
195
+ name: string;
196
+
197
+ /**
198
+ * The ordinal number of the test.
199
+ */
200
+ testNumber: number;
201
+
202
+ /**
203
+ * Present if `context.todo` is called.
204
+ */
205
+ todo?: string;
206
+
207
+ /**
208
+ * Present if `context.skip` is called.
209
+ */
210
+ skip?: string;
211
+ }
212
+
213
+ /**
214
+ * An instance of `TestContext` is passed to each test function in order to interact with the
215
+ * test runner. However, the `TestContext` constructor is not exposed as part of the API.
216
+ * @since v18.0.0
217
+ */
218
+ interface TestContext {
219
+ /**
220
+ * This function is used to write TAP diagnostics to the output. Any diagnostic information is
221
+ * included at the end of the test's results. This function does not return a value.
222
+ * @param message Message to be displayed as a TAP diagnostic.
223
+ * @since v18.0.0
224
+ */
225
+ diagnostic(message: string): void;
226
+
227
+ /**
228
+ * If `shouldRunOnlyTests` is truthy, the test context will only run tests that have the `only`
229
+ * option set. Otherwise, all tests are run. If Node.js was not started with the `--test-only`
230
+ * command-line option, this function is a no-op.
231
+ * @param shouldRunOnlyTests Whether or not to run `only` tests.
232
+ * @since v18.0.0
233
+ */
234
+ runOnly(shouldRunOnlyTests: boolean): void;
235
+
236
+ /**
237
+ * This function causes the test's output to indicate the test as skipped. If `message` is
238
+ * provided, it is included in the TAP output. Calling `skip()` does not terminate execution of
239
+ * the test function. This function does not return a value.
240
+ * @param message Optional skip message to be displayed in TAP output.
241
+ * @since v18.0.0
242
+ */
243
+ skip(message?: string): void;
244
+
245
+ /**
246
+ * This function adds a `TODO` directive to the test's output. If `message` is provided, it is
247
+ * included in the TAP output. Calling `todo()` does not terminate execution of the test
248
+ * function. This function does not return a value.
249
+ * @param message Optional `TODO` message to be displayed in TAP output.
250
+ * @since v18.0.0
251
+ */
252
+ todo(message?: string): void;
253
+
254
+ /**
255
+ * This function is used to create subtests under the current test. This function behaves in
256
+ * the same fashion as the top level {@link test} function.
257
+ * @since v18.0.0
258
+ * @param name The name of the test, which is displayed when reporting test results.
259
+ * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
260
+ * @param options Configuration options for the test
261
+ * @param fn The function under test. This first argument to this function is a
262
+ * {@link TestContext} object. If the test uses callbacks, the callback function is
263
+ * passed as the second argument. Default: A no-op function.
264
+ * @returns A {@link Promise} resolved with `undefined` once the test completes.
265
+ */
266
+ test: typeof test;
267
+ }
268
+
269
+ interface TestOptions {
270
+ /**
271
+ * The number of tests that can be run at the same time. If unspecified, subtests inherit this
272
+ * value from their parent.
273
+ * @default 1
274
+ */
275
+ concurrency?: number;
276
+
277
+ /**
278
+ * If truthy, and the test context is configured to run `only` tests, then this test will be
279
+ * run. Otherwise, the test is skipped.
280
+ * @default false
281
+ */
282
+ only?: boolean;
283
+
284
+ /**
285
+ * Allows aborting an in-progress test.
286
+ * @since v18.8.0
287
+ */
288
+ signal?: AbortSignal;
289
+
290
+ /**
291
+ * If truthy, the test is skipped. If a string is provided, that string is displayed in the
292
+ * test results as the reason for skipping the test.
293
+ * @default false
294
+ */
295
+ skip?: boolean | string;
296
+
297
+ /**
298
+ * A number of milliseconds the test will fail after. If unspecified, subtests inherit this
299
+ * value from their parent.
300
+ * @default Infinity
301
+ * @since v18.7.0
302
+ */
303
+ timeout?: number;
304
+
305
+ /**
306
+ * If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in
307
+ * the test results as the reason why the test is `TODO`.
308
+ * @default false
309
+ */
310
+ todo?: boolean | string;
311
+ }
312
+
313
+ export { test as default, run, test, describe, it };
314
+ }
File without changes
@@ -6,7 +6,7 @@
6
6
  * The timer functions within Node.js implement a similar API as the timers API
7
7
  * provided by Web Browsers but use a different internal implementation that is
8
8
  * built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout).
9
- * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/timers.js)
9
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/timers.js)
10
10
  */
11
11
  declare module 'timers' {
12
12
  import { Abortable } from 'node:events';