@types/node 18.11.5 → 20.2.5

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 (97) hide show
  1. node/README.md +2 -2
  2. node/assert.d.ts +86 -75
  3. node/async_hooks.d.ts +66 -37
  4. node/buffer.d.ts +193 -100
  5. node/child_process.d.ts +82 -56
  6. node/cluster.d.ts +12 -12
  7. node/console.d.ts +5 -5
  8. node/crypto.d.ts +233 -235
  9. node/dgram.d.ts +15 -15
  10. node/diagnostics_channel.d.ts +59 -21
  11. node/dns/promises.d.ts +50 -6
  12. node/dns.d.ts +26 -17
  13. node/domain.d.ts +4 -4
  14. node/events.d.ts +111 -65
  15. node/fs/promises.d.ts +99 -47
  16. node/fs.d.ts +244 -73
  17. node/globals.d.ts +6 -3
  18. node/http.d.ts +265 -148
  19. node/http2.d.ts +42 -47
  20. node/https.d.ts +53 -153
  21. node/index.d.ts +2 -1
  22. node/inspector.d.ts +10 -3
  23. node/module.d.ts +6 -4
  24. node/net.d.ts +32 -15
  25. node/os.d.ts +27 -16
  26. node/package.json +9 -4
  27. node/path.d.ts +4 -4
  28. node/perf_hooks.d.ts +28 -15
  29. node/process.d.ts +49 -46
  30. node/punycode.d.ts +1 -1
  31. node/querystring.d.ts +5 -5
  32. node/readline/promises.d.ts +65 -63
  33. node/readline.d.ts +32 -159
  34. node/repl.d.ts +20 -20
  35. node/stream/consumers.d.ts +1 -1
  36. node/stream.d.ts +950 -869
  37. node/string_decoder.d.ts +6 -6
  38. node/test.d.ts +877 -139
  39. node/timers/promises.d.ts +26 -1
  40. node/timers.d.ts +125 -4
  41. node/tls.d.ts +120 -29
  42. node/trace_events.d.ts +20 -9
  43. node/ts4.8/assert.d.ts +86 -75
  44. node/ts4.8/async_hooks.d.ts +66 -37
  45. node/ts4.8/buffer.d.ts +193 -101
  46. node/ts4.8/child_process.d.ts +82 -56
  47. node/ts4.8/cluster.d.ts +12 -12
  48. node/ts4.8/console.d.ts +5 -5
  49. node/ts4.8/crypto.d.ts +230 -233
  50. node/ts4.8/dgram.d.ts +15 -15
  51. node/ts4.8/diagnostics_channel.d.ts +59 -21
  52. node/ts4.8/dns/promises.d.ts +50 -6
  53. node/ts4.8/dns.d.ts +26 -17
  54. node/ts4.8/domain.d.ts +4 -4
  55. node/ts4.8/events.d.ts +111 -65
  56. node/ts4.8/fs/promises.d.ts +97 -46
  57. node/ts4.8/fs.d.ts +244 -73
  58. node/ts4.8/globals.d.ts +21 -12
  59. node/ts4.8/http.d.ts +265 -148
  60. node/ts4.8/http2.d.ts +42 -47
  61. node/ts4.8/https.d.ts +53 -153
  62. node/ts4.8/inspector.d.ts +10 -3
  63. node/ts4.8/module.d.ts +6 -4
  64. node/ts4.8/net.d.ts +33 -16
  65. node/ts4.8/os.d.ts +27 -16
  66. node/ts4.8/path.d.ts +4 -4
  67. node/ts4.8/perf_hooks.d.ts +28 -15
  68. node/ts4.8/process.d.ts +49 -46
  69. node/ts4.8/punycode.d.ts +1 -1
  70. node/ts4.8/querystring.d.ts +5 -5
  71. node/ts4.8/readline/promises.d.ts +65 -63
  72. node/ts4.8/readline.d.ts +32 -159
  73. node/ts4.8/repl.d.ts +20 -20
  74. node/ts4.8/stream/consumers.d.ts +1 -1
  75. node/ts4.8/stream.d.ts +192 -140
  76. node/ts4.8/string_decoder.d.ts +6 -6
  77. node/ts4.8/test.d.ts +877 -139
  78. node/ts4.8/timers/promises.d.ts +26 -1
  79. node/ts4.8/timers.d.ts +125 -4
  80. node/ts4.8/tls.d.ts +120 -29
  81. node/ts4.8/trace_events.d.ts +20 -9
  82. node/ts4.8/tty.d.ts +4 -5
  83. node/ts4.8/url.d.ts +46 -42
  84. node/ts4.8/util.d.ts +325 -123
  85. node/ts4.8/v8.d.ts +253 -14
  86. node/ts4.8/vm.d.ts +417 -32
  87. node/ts4.8/wasi.d.ts +13 -19
  88. node/ts4.8/worker_threads.d.ts +38 -34
  89. node/ts4.8/zlib.d.ts +11 -11
  90. node/tty.d.ts +4 -5
  91. node/url.d.ts +46 -42
  92. node/util.d.ts +325 -123
  93. node/v8.d.ts +253 -14
  94. node/vm.d.ts +417 -32
  95. node/wasi.d.ts +13 -19
  96. node/worker_threads.d.ts +38 -34
  97. node/zlib.d.ts +11 -11
node/wasi.d.ts CHANGED
@@ -3,26 +3,23 @@
3
3
  * underlying operating system via a collection of POSIX-like functions.
4
4
  *
5
5
  * ```js
6
- * import { readFile } from 'fs/promises';
6
+ * import { readFile } from 'node:fs/promises';
7
7
  * import { WASI } from 'wasi';
8
- * import { argv, env } from 'process';
8
+ * import { argv, env } from 'node:process';
9
9
  *
10
10
  * const wasi = new WASI({
11
+ * version: 'preview1',
11
12
  * args: argv,
12
13
  * env,
13
14
  * preopens: {
14
- * '/sandbox': '/some/real/path/that/wasm/can/access'
15
- * }
15
+ * '/sandbox': '/some/real/path/that/wasm/can/access',
16
+ * },
16
17
  * });
17
18
  *
18
- * // Some WASI binaries require:
19
- * // const importObject = { wasi_unstable: wasi.wasiImport };
20
- * const importObject = { wasi_snapshot_preview1: wasi.wasiImport };
21
- *
22
19
  * const wasm = await WebAssembly.compile(
23
- * await readFile(new URL('./demo.wasm', import.meta.url))
20
+ * await readFile(new URL('./demo.wasm', import.meta.url)),
24
21
  * );
25
- * const instance = await WebAssembly.instantiate(wasm, importObject);
22
+ * const instance = await WebAssembly.instantiate(wasm, wasi.getImportObject());
26
23
  *
27
24
  * wasi.start(instance);
28
25
  * ```
@@ -64,11 +61,8 @@
64
61
  * ```console
65
62
  * $ wat2wasm demo.wat
66
63
  * ```
67
- *
68
- * The `--experimental-wasi-unstable-preview1` CLI argument is needed for this
69
- * example to run.
70
64
  * @experimental
71
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/wasi.js)
65
+ * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/wasi.js)
72
66
  */
73
67
  declare module 'wasi' {
74
68
  interface WASIOptions {
@@ -91,11 +85,11 @@ declare module 'wasi' {
91
85
  */
92
86
  preopens?: NodeJS.Dict<string> | undefined;
93
87
  /**
94
- * By default, WASI applications terminate the Node.js
95
- * process via the `__wasi_proc_exit()` function. Setting this option to `true`
96
- * causes `wasi.start()` to return the exit code rather than terminate the
97
- * process.
98
- * @default false
88
+ * By default, when WASI applications call `__wasi_proc_exit()`
89
+ * `wasi.start()` will return with the exit code specified rather than terminatng the process.
90
+ * Setting this option to `false` will cause the Node.js process to exit with
91
+ * the specified exit code instead.
92
+ * @default true
99
93
  */
100
94
  returnOnExit?: boolean | undefined;
101
95
  /**
node/worker_threads.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * The `worker_threads` module enables the use of threads that execute JavaScript
3
- * in parallel. To access it:
2
+ * The `node:worker_threads` module enables the use of threads that execute
3
+ * JavaScript in parallel. To access it:
4
4
  *
5
5
  * ```js
6
- * const worker = require('worker_threads');
6
+ * const worker = require('node:worker_threads');
7
7
  * ```
8
8
  *
9
9
  * Workers (threads) are useful for performing CPU-intensive JavaScript operations.
@@ -15,14 +15,14 @@
15
15
  *
16
16
  * ```js
17
17
  * const {
18
- * Worker, isMainThread, parentPort, workerData
19
- * } = require('worker_threads');
18
+ * Worker, isMainThread, parentPort, workerData,
19
+ * } = require('node:worker_threads');
20
20
  *
21
21
  * if (isMainThread) {
22
22
  * module.exports = function parseJSAsync(script) {
23
23
  * return new Promise((resolve, reject) => {
24
24
  * const worker = new Worker(__filename, {
25
- * workerData: script
25
+ * workerData: script,
26
26
  * });
27
27
  * worker.on('message', resolve);
28
28
  * worker.on('error', reject);
@@ -49,7 +49,7 @@
49
49
  *
50
50
  * Worker threads inherit non-process-specific options by default. Refer to `Worker constructor options` to know how to customize worker thread options,
51
51
  * specifically `argv` and `execArgv` options.
52
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/worker_threads.js)
52
+ * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/worker_threads.js)
53
53
  */
54
54
  declare module 'worker_threads' {
55
55
  import { Blob } from 'node:buffer';
@@ -72,7 +72,7 @@ declare module 'worker_threads' {
72
72
  * The `MessageChannel` has no methods of its own. `new MessageChannel()`yields an object with `port1` and `port2` properties, which refer to linked `MessagePort` instances.
73
73
  *
74
74
  * ```js
75
- * const { MessageChannel } = require('worker_threads');
75
+ * const { MessageChannel } = require('node:worker_threads');
76
76
  *
77
77
  * const { port1, port2 } = new MessageChannel();
78
78
  * port1.on('message', (message) => console.log('received', message));
@@ -121,7 +121,7 @@ declare module 'worker_threads' {
121
121
  * * `value` may not contain native (C++-backed) objects other than:
122
122
  *
123
123
  * ```js
124
- * const { MessageChannel } = require('worker_threads');
124
+ * const { MessageChannel } = require('node:worker_threads');
125
125
  * const { port1, port2 } = new MessageChannel();
126
126
  *
127
127
  * port1.on('message', (message) => console.log(message));
@@ -132,7 +132,7 @@ declare module 'worker_threads' {
132
132
  * port2.postMessage(circularData);
133
133
  * ```
134
134
  *
135
- * `transferList` may be a list of [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), `MessagePort` and `FileHandle` objects.
135
+ * `transferList` may be a list of [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), `MessagePort`, and `FileHandle` objects.
136
136
  * After transferring, they are not usable on the sending side of the channel
137
137
  * anymore (even if they are not contained in `value`). Unlike with `child processes`, transferring handles such as network sockets is currently
138
138
  * not supported.
@@ -143,7 +143,7 @@ declare module 'worker_threads' {
143
143
  * `value` may still contain `ArrayBuffer` instances that are not in`transferList`; in that case, the underlying memory is copied rather than moved.
144
144
  *
145
145
  * ```js
146
- * const { MessageChannel } = require('worker_threads');
146
+ * const { MessageChannel } = require('node:worker_threads');
147
147
  * const { port1, port2 } = new MessageChannel();
148
148
  *
149
149
  * port1.on('message', (message) => console.log(message));
@@ -170,7 +170,7 @@ declare module 'worker_threads' {
170
170
  * posting without having side effects.
171
171
  *
172
172
  * For more information on the serialization and deserialization mechanisms
173
- * behind this API, see the `serialization API of the v8 module`.
173
+ * behind this API, see the `serialization API of the node:v8 module`.
174
174
  * @since v10.5.0
175
175
  */
176
176
  postMessage(value: any, transferList?: ReadonlyArray<TransferListItem>): void;
@@ -262,6 +262,12 @@ declare module 'worker_threads' {
262
262
  * @default true
263
263
  */
264
264
  trackUnmanagedFds?: boolean | undefined;
265
+ /**
266
+ * An optional `name` to be appended to the worker title
267
+ * for debuggin/identification purposes, making the final title as
268
+ * `[worker ${id}] ${name}`.
269
+ */
270
+ name?: string | undefined;
265
271
  }
266
272
  interface ResourceLimits {
267
273
  /**
@@ -288,9 +294,9 @@ declare module 'worker_threads' {
288
294
  *
289
295
  * Notable differences inside a Worker environment are:
290
296
  *
291
- * * The `process.stdin`, `process.stdout` and `process.stderr` may be redirected by the parent thread.
292
- * * The `require('worker_threads').isMainThread` property is set to `false`.
293
- * * The `require('worker_threads').parentPort` message port is available.
297
+ * * The `process.stdin`, `process.stdout`, and `process.stderr` streams may be redirected by the parent thread.
298
+ * * The `require('node:worker_threads').isMainThread` property is set to `false`.
299
+ * * The `require('node:worker_threads').parentPort` message port is available.
294
300
  * * `process.exit()` does not stop the whole program, just the single thread,
295
301
  * and `process.abort()` is not available.
296
302
  * * `process.chdir()` and `process` methods that set group or user ids
@@ -307,11 +313,11 @@ declare module 'worker_threads' {
307
313
  *
308
314
  * Creating `Worker` instances inside of other `Worker`s is possible.
309
315
  *
310
- * Like [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and the `cluster module`, two-way communication can be
311
- * achieved through inter-thread message passing. Internally, a `Worker` has a
312
- * built-in pair of `MessagePort` s that are already associated with each other
313
- * when the `Worker` is created. While the `MessagePort` object on the parent side
314
- * is not directly exposed, its functionalities are exposed through `worker.postMessage()` and the `worker.on('message')` event
316
+ * Like [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and the `node:cluster module`, two-way communication
317
+ * can be achieved through inter-thread message passing. Internally, a `Worker` has
318
+ * a built-in pair of `MessagePort` s that are already associated with each
319
+ * other when the `Worker` is created. While the `MessagePort` object on the parent
320
+ * side is not directly exposed, its functionalities are exposed through `worker.postMessage()` and the `worker.on('message')` event
315
321
  * on the `Worker` object for the parent thread.
316
322
  *
317
323
  * To create custom messaging channels (which is encouraged over using the default
@@ -324,10 +330,10 @@ declare module 'worker_threads' {
324
330
  * the thread barrier.
325
331
  *
326
332
  * ```js
327
- * const assert = require('assert');
333
+ * const assert = require('node:assert');
328
334
  * const {
329
- * Worker, MessageChannel, MessagePort, isMainThread, parentPort
330
- * } = require('worker_threads');
335
+ * Worker, MessageChannel, MessagePort, isMainThread, parentPort,
336
+ * } = require('node:worker_threads');
331
337
  * if (isMainThread) {
332
338
  * const worker = new Worker(__filename);
333
339
  * const subChannel = new MessageChannel();
@@ -367,7 +373,7 @@ declare module 'worker_threads' {
367
373
  readonly stderr: Readable;
368
374
  /**
369
375
  * An integer identifier for the referenced thread. Inside the worker thread,
370
- * it is available as `require('worker_threads').threadId`.
376
+ * it is available as `require('node:worker_threads').threadId`.
371
377
  * This value is unique for each `Worker` instance inside a single process.
372
378
  * @since v10.5.0
373
379
  */
@@ -394,7 +400,7 @@ declare module 'worker_threads' {
394
400
  */
395
401
  constructor(filename: string | URL, options?: WorkerOptions);
396
402
  /**
397
- * Send a message to the worker that is received via `require('worker_threads').parentPort.on('message')`.
403
+ * Send a message to the worker that is received via `require('node:worker_threads').parentPort.on('message')`.
398
404
  * See `port.postMessage()` for more details.
399
405
  * @since v10.5.0
400
406
  */
@@ -488,8 +494,8 @@ declare module 'worker_threads' {
488
494
  * const {
489
495
  * isMainThread,
490
496
  * BroadcastChannel,
491
- * Worker
492
- * } = require('worker_threads');
497
+ * Worker,
498
+ * } = require('node:worker_threads');
493
499
  *
494
500
  * const bc = new BroadcastChannel('hello');
495
501
  *
@@ -543,7 +549,7 @@ declare module 'worker_threads' {
543
549
  * This operation cannot be undone.
544
550
  *
545
551
  * ```js
546
- * const { MessageChannel, markAsUntransferable } = require('worker_threads');
552
+ * const { MessageChannel, markAsUntransferable } = require('node:worker_threads');
547
553
  *
548
554
  * const pooledBuffer = new ArrayBuffer(8);
549
555
  * const typedArray1 = new Uint8Array(pooledBuffer);
@@ -585,10 +591,10 @@ declare module 'worker_threads' {
585
591
  function moveMessagePortToContext(port: MessagePort, contextifiedSandbox: Context): MessagePort;
586
592
  /**
587
593
  * Receive a single message from a given `MessagePort`. If no message is available,`undefined` is returned, otherwise an object with a single `message` property
588
- * that contains the message payload, corresponding to the oldest message in the`MessagePort`’s queue.
594
+ * that contains the message payload, corresponding to the oldest message in the`MessagePort`'s queue.
589
595
  *
590
596
  * ```js
591
- * const { MessageChannel, receiveMessageOnPort } = require('worker_threads');
597
+ * const { MessageChannel, receiveMessageOnPort } = require('node:worker_threads');
592
598
  * const { port1, port2 } = new MessageChannel();
593
599
  * port1.postMessage({ hello: 'world' });
594
600
  *
@@ -619,7 +625,7 @@ declare module 'worker_threads' {
619
625
  * isMainThread,
620
626
  * setEnvironmentData,
621
627
  * getEnvironmentData,
622
- * } = require('worker_threads');
628
+ * } = require('node:worker_threads');
623
629
  *
624
630
  * if (isMainThread) {
625
631
  * setEnvironmentData('Hello', 'World!');
@@ -658,7 +664,6 @@ declare module 'worker_threads' {
658
664
  }
659
665
  ? T
660
666
  : typeof _BroadcastChannel;
661
-
662
667
  /**
663
668
  * `MessageChannel` class is a global reference for `require('worker_threads').MessageChannel`
664
669
  * https://nodejs.org/api/globals.html#messagechannel
@@ -670,13 +675,12 @@ declare module 'worker_threads' {
670
675
  }
671
676
  ? T
672
677
  : typeof _MessageChannel;
673
-
674
678
  /**
675
679
  * `MessagePort` class is a global reference for `require('worker_threads').MessagePort`
676
680
  * https://nodejs.org/api/globals.html#messageport
677
681
  * @since v15.0.0
678
682
  */
679
- var MessagePort: typeof globalThis extends {
683
+ var MessagePort: typeof globalThis extends {
680
684
  onmessage: any;
681
685
  MessagePort: infer T;
682
686
  }
node/zlib.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
- * The `zlib` module provides compression functionality implemented using Gzip,
3
- * Deflate/Inflate, and Brotli.
2
+ * The `node:zlib` module provides compression functionality implemented using
3
+ * Gzip, Deflate/Inflate, and Brotli.
4
4
  *
5
5
  * To access it:
6
6
  *
7
7
  * ```js
8
- * const zlib = require('zlib');
8
+ * const zlib = require('node:zlib');
9
9
  * ```
10
10
  *
11
11
  * Compression and decompression are built around the Node.js `Streams API`.
@@ -15,12 +15,12 @@
15
15
  * stream:
16
16
  *
17
17
  * ```js
18
- * const { createGzip } = require('zlib');
19
- * const { pipeline } = require('stream');
18
+ * const { createGzip } = require('node:zlib');
19
+ * const { pipeline } = require('node:stream');
20
20
  * const {
21
21
  * createReadStream,
22
- * createWriteStream
23
- * } = require('fs');
22
+ * createWriteStream,
23
+ * } = require('node:fs');
24
24
  *
25
25
  * const gzip = createGzip();
26
26
  * const source = createReadStream('input.txt');
@@ -35,7 +35,7 @@
35
35
  *
36
36
  * // Or, Promisified
37
37
  *
38
- * const { promisify } = require('util');
38
+ * const { promisify } = require('node:util');
39
39
  * const pipe = promisify(pipeline);
40
40
  *
41
41
  * async function do_gzip(input, output) {
@@ -55,7 +55,7 @@
55
55
  * It is also possible to compress or decompress data in a single step:
56
56
  *
57
57
  * ```js
58
- * const { deflate, unzip } = require('zlib');
58
+ * const { deflate, unzip } = require('node:zlib');
59
59
  *
60
60
  * const input = '.................................';
61
61
  * deflate(input, (err, buffer) => {
@@ -77,7 +77,7 @@
77
77
  *
78
78
  * // Or, Promisified
79
79
  *
80
- * const { promisify } = require('util');
80
+ * const { promisify } = require('node:util');
81
81
  * const do_unzip = promisify(unzip);
82
82
  *
83
83
  * do_unzip(buffer)
@@ -88,7 +88,7 @@
88
88
  * });
89
89
  * ```
90
90
  * @since v0.5.8
91
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/zlib.js)
91
+ * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/zlib.js)
92
92
  */
93
93
  declare module 'zlib' {
94
94
  import * as stream from 'node:stream';