@types/node 24.10.2 → 25.0.0

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 (81) hide show
  1. node/README.md +1 -1
  2. node/assert/strict.d.ts +5 -11
  3. node/assert.d.ts +9 -169
  4. node/async_hooks.d.ts +8 -8
  5. node/buffer.buffer.d.ts +1 -7
  6. node/buffer.d.ts +44 -168
  7. node/child_process.d.ts +16 -64
  8. node/cluster.d.ts +240 -332
  9. node/console.d.ts +49 -351
  10. node/constants.d.ts +3 -4
  11. node/crypto.d.ts +279 -1631
  12. node/dgram.d.ts +15 -51
  13. node/diagnostics_channel.d.ts +4 -4
  14. node/dns/promises.d.ts +3 -3
  15. node/dns.d.ts +131 -132
  16. node/domain.d.ts +13 -17
  17. node/events.d.ts +719 -649
  18. node/fs/promises.d.ts +7 -8
  19. node/fs.d.ts +417 -455
  20. node/globals.d.ts +6 -26
  21. node/globals.typedarray.d.ts +60 -0
  22. node/http.d.ts +263 -254
  23. node/http2.d.ts +528 -804
  24. node/https.d.ts +59 -239
  25. node/index.d.ts +15 -1
  26. node/inspector/promises.d.ts +41 -0
  27. node/inspector.d.ts +6 -59
  28. node/inspector.generated.d.ts +3 -10
  29. node/module.d.ts +47 -122
  30. node/net.d.ts +63 -184
  31. node/os.d.ts +6 -6
  32. node/package.json +2 -2
  33. node/path/posix.d.ts +8 -0
  34. node/path/win32.d.ts +8 -0
  35. node/path.d.ts +120 -133
  36. node/perf_hooks.d.ts +282 -643
  37. node/process.d.ts +151 -128
  38. node/punycode.d.ts +5 -5
  39. node/querystring.d.ts +4 -4
  40. node/quic.d.ts +910 -0
  41. node/readline/promises.d.ts +3 -3
  42. node/readline.d.ts +67 -120
  43. node/repl.d.ts +75 -98
  44. node/sea.d.ts +1 -1
  45. node/sqlite.d.ts +2 -2
  46. node/stream/consumers.d.ts +10 -10
  47. node/stream/promises.d.ts +136 -15
  48. node/stream/web.d.ts +176 -453
  49. node/stream.d.ts +555 -478
  50. node/string_decoder.d.ts +4 -4
  51. node/test/reporters.d.ts +96 -0
  52. node/test.d.ts +80 -180
  53. node/timers/promises.d.ts +4 -4
  54. node/timers.d.ts +4 -130
  55. node/tls.d.ts +102 -177
  56. node/trace_events.d.ts +9 -9
  57. node/ts5.6/buffer.buffer.d.ts +1 -7
  58. node/ts5.6/index.d.ts +15 -1
  59. node/ts5.7/index.d.ts +15 -1
  60. node/tty.d.ts +58 -16
  61. node/url.d.ts +54 -592
  62. node/util/types.d.ts +558 -0
  63. node/util.d.ts +117 -792
  64. node/v8.d.ts +32 -5
  65. node/vm.d.ts +13 -13
  66. node/wasi.d.ts +4 -4
  67. node/web-globals/abortcontroller.d.ts +27 -2
  68. node/web-globals/blob.d.ts +23 -0
  69. node/web-globals/console.d.ts +9 -0
  70. node/web-globals/crypto.d.ts +7 -0
  71. node/web-globals/encoding.d.ts +11 -0
  72. node/web-globals/events.d.ts +9 -0
  73. node/web-globals/fetch.d.ts +4 -0
  74. node/web-globals/importmeta.d.ts +13 -0
  75. node/web-globals/messaging.d.ts +23 -0
  76. node/web-globals/performance.d.ts +45 -0
  77. node/web-globals/streams.d.ts +93 -0
  78. node/web-globals/timers.d.ts +44 -0
  79. node/web-globals/url.d.ts +24 -0
  80. node/worker_threads.d.ts +176 -358
  81. node/zlib.d.ts +8 -71
@@ -3,36 +3,36 @@
3
3
  * streams.
4
4
  * @since v16.7.0
5
5
  */
6
- declare module "stream/consumers" {
7
- import { Blob as NodeBlob, NonSharedBuffer } from "node:buffer";
8
- import { ReadableStream as WebReadableStream } from "node:stream/web";
6
+ declare module "node:stream/consumers" {
7
+ import { Blob, NonSharedBuffer } from "node:buffer";
8
+ import { ReadableStream } from "node:stream/web";
9
9
  /**
10
10
  * @since v16.7.0
11
11
  * @returns Fulfills with an `ArrayBuffer` containing the full contents of the stream.
12
12
  */
13
- function arrayBuffer(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<ArrayBuffer>;
13
+ function arrayBuffer(stream: ReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<ArrayBuffer>;
14
14
  /**
15
15
  * @since v16.7.0
16
16
  * @returns Fulfills with a `Blob` containing the full contents of the stream.
17
17
  */
18
- function blob(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<NodeBlob>;
18
+ function blob(stream: ReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<Blob>;
19
19
  /**
20
20
  * @since v16.7.0
21
21
  * @returns Fulfills with a `Buffer` containing the full contents of the stream.
22
22
  */
23
- function buffer(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<NonSharedBuffer>;
23
+ function buffer(stream: ReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<NonSharedBuffer>;
24
24
  /**
25
25
  * @since v16.7.0
26
26
  * @returns Fulfills with the contents of the stream parsed as a
27
27
  * UTF-8 encoded string that is then passed through `JSON.parse()`.
28
28
  */
29
- function json(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<unknown>;
29
+ function json(stream: ReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<unknown>;
30
30
  /**
31
31
  * @since v16.7.0
32
32
  * @returns Fulfills with the contents of the stream parsed as a UTF-8 encoded string.
33
33
  */
34
- function text(stream: WebReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<string>;
34
+ function text(stream: ReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<string>;
35
35
  }
36
- declare module "node:stream/consumers" {
37
- export * from "stream/consumers";
36
+ declare module "stream/consumers" {
37
+ export * from "node:stream/consumers";
38
38
  }
node/stream/promises.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- declare module "stream/promises" {
1
+ declare module "node:stream/promises" {
2
+ import { Abortable } from "node:events";
2
3
  import {
3
4
  FinishedOptions as _FinishedOptions,
4
5
  PipelineDestination,
5
- PipelineOptions,
6
- PipelinePromise,
7
6
  PipelineSource,
8
7
  PipelineTransform,
9
8
  } from "node:stream";
9
+ import { ReadableStream, WritableStream } from "node:stream/web";
10
10
  interface FinishedOptions extends _FinishedOptions {
11
11
  /**
12
12
  * If true, removes the listeners registered by this function before the promise is fulfilled.
@@ -14,15 +14,130 @@ declare module "stream/promises" {
14
14
  */
15
15
  cleanup?: boolean | undefined;
16
16
  }
17
+ /**
18
+ * ```js
19
+ * import { finished } from 'node:stream/promises';
20
+ * import { createReadStream } from 'node:fs';
21
+ *
22
+ * const rs = createReadStream('archive.tar');
23
+ *
24
+ * async function run() {
25
+ * await finished(rs);
26
+ * console.log('Stream is done reading.');
27
+ * }
28
+ *
29
+ * run().catch(console.error);
30
+ * rs.resume(); // Drain the stream.
31
+ * ```
32
+ *
33
+ * The `finished` API also provides a [callback version](https://nodejs.org/docs/latest-v25.x/api/stream.html#streamfinishedstream-options-callback).
34
+ *
35
+ * `stream.finished()` leaves dangling event listeners (in particular
36
+ * `'error'`, `'end'`, `'finish'` and `'close'`) after the returned promise is
37
+ * resolved or rejected. The reason for this is so that unexpected `'error'`
38
+ * events (due to incorrect stream implementations) do not cause unexpected
39
+ * crashes. If this is unwanted behavior then `options.cleanup` should be set to
40
+ * `true`:
41
+ *
42
+ * ```js
43
+ * await finished(rs, { cleanup: true });
44
+ * ```
45
+ * @since v15.0.0
46
+ * @returns Fulfills when the stream is no longer readable or writable.
47
+ */
17
48
  function finished(
18
- stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream,
49
+ stream: NodeJS.ReadableStream | NodeJS.WritableStream | ReadableStream | WritableStream,
19
50
  options?: FinishedOptions,
20
51
  ): Promise<void>;
52
+ interface PipelineOptions extends Abortable {
53
+ end?: boolean | undefined;
54
+ }
55
+ type PipelineResult<S extends PipelineDestination<any, any>> = S extends (...args: any[]) => PromiseLike<infer R>
56
+ ? Promise<R>
57
+ : Promise<void>;
58
+ /**
59
+ * ```js
60
+ * import { pipeline } from 'node:stream/promises';
61
+ * import { createReadStream, createWriteStream } from 'node:fs';
62
+ * import { createGzip } from 'node:zlib';
63
+ *
64
+ * await pipeline(
65
+ * createReadStream('archive.tar'),
66
+ * createGzip(),
67
+ * createWriteStream('archive.tar.gz'),
68
+ * );
69
+ * console.log('Pipeline succeeded.');
70
+ * ```
71
+ *
72
+ * To use an `AbortSignal`, pass it inside an options object, as the last argument.
73
+ * When the signal is aborted, `destroy` will be called on the underlying pipeline,
74
+ * with an `AbortError`.
75
+ *
76
+ * ```js
77
+ * import { pipeline } from 'node:stream/promises';
78
+ * import { createReadStream, createWriteStream } from 'node:fs';
79
+ * import { createGzip } from 'node:zlib';
80
+ *
81
+ * const ac = new AbortController();
82
+ * const { signal } = ac;
83
+ * setImmediate(() => ac.abort());
84
+ * try {
85
+ * await pipeline(
86
+ * createReadStream('archive.tar'),
87
+ * createGzip(),
88
+ * createWriteStream('archive.tar.gz'),
89
+ * { signal },
90
+ * );
91
+ * } catch (err) {
92
+ * console.error(err); // AbortError
93
+ * }
94
+ * ```
95
+ *
96
+ * The `pipeline` API also supports async generators:
97
+ *
98
+ * ```js
99
+ * import { pipeline } from 'node:stream/promises';
100
+ * import { createReadStream, createWriteStream } from 'node:fs';
101
+ *
102
+ * await pipeline(
103
+ * createReadStream('lowercase.txt'),
104
+ * async function* (source, { signal }) {
105
+ * source.setEncoding('utf8'); // Work with strings rather than `Buffer`s.
106
+ * for await (const chunk of source) {
107
+ * yield await processChunk(chunk, { signal });
108
+ * }
109
+ * },
110
+ * createWriteStream('uppercase.txt'),
111
+ * );
112
+ * console.log('Pipeline succeeded.');
113
+ * ```
114
+ *
115
+ * Remember to handle the `signal` argument passed into the async generator.
116
+ * Especially in the case where the async generator is the source for the
117
+ * pipeline (i.e. first argument) or the pipeline will never complete.
118
+ *
119
+ * ```js
120
+ * import { pipeline } from 'node:stream/promises';
121
+ * import fs from 'node:fs';
122
+ * await pipeline(
123
+ * async function* ({ signal }) {
124
+ * await someLongRunningfn({ signal });
125
+ * yield 'asd';
126
+ * },
127
+ * fs.createWriteStream('uppercase.txt'),
128
+ * );
129
+ * console.log('Pipeline succeeded.');
130
+ * ```
131
+ *
132
+ * The `pipeline` API provides [callback version](https://nodejs.org/docs/latest-v25.x/api/stream.html#streampipelinesource-transforms-destination-callback):
133
+ * @since v15.0.0
134
+ * @returns Fulfills when the pipeline is complete.
135
+ */
21
136
  function pipeline<A extends PipelineSource<any>, B extends PipelineDestination<A, any>>(
22
137
  source: A,
23
138
  destination: B,
24
139
  options?: PipelineOptions,
25
- ): PipelinePromise<B>;
140
+ ): PipelineResult<B>;
26
141
  function pipeline<
27
142
  A extends PipelineSource<any>,
28
143
  T1 extends PipelineTransform<A, any>,
@@ -32,7 +147,7 @@ declare module "stream/promises" {
32
147
  transform1: T1,
33
148
  destination: B,
34
149
  options?: PipelineOptions,
35
- ): PipelinePromise<B>;
150
+ ): PipelineResult<B>;
36
151
  function pipeline<
37
152
  A extends PipelineSource<any>,
38
153
  T1 extends PipelineTransform<A, any>,
@@ -44,7 +159,7 @@ declare module "stream/promises" {
44
159
  transform2: T2,
45
160
  destination: B,
46
161
  options?: PipelineOptions,
47
- ): PipelinePromise<B>;
162
+ ): PipelineResult<B>;
48
163
  function pipeline<
49
164
  A extends PipelineSource<any>,
50
165
  T1 extends PipelineTransform<A, any>,
@@ -58,7 +173,7 @@ declare module "stream/promises" {
58
173
  transform3: T3,
59
174
  destination: B,
60
175
  options?: PipelineOptions,
61
- ): PipelinePromise<B>;
176
+ ): PipelineResult<B>;
62
177
  function pipeline<
63
178
  A extends PipelineSource<any>,
64
179
  T1 extends PipelineTransform<A, any>,
@@ -74,17 +189,23 @@ declare module "stream/promises" {
74
189
  transform4: T4,
75
190
  destination: B,
76
191
  options?: PipelineOptions,
77
- ): PipelinePromise<B>;
192
+ ): PipelineResult<B>;
78
193
  function pipeline(
79
- streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>,
194
+ streams: readonly [PipelineSource<any>, ...PipelineTransform<any, any>[], PipelineDestination<any, any>],
80
195
  options?: PipelineOptions,
81
196
  ): Promise<void>;
82
197
  function pipeline(
83
- stream1: NodeJS.ReadableStream,
84
- stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
85
- ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | PipelineOptions>
198
+ ...streams: [PipelineSource<any>, ...PipelineTransform<any, any>[], PipelineDestination<any, any>]
199
+ ): Promise<void>;
200
+ function pipeline(
201
+ ...streams: [
202
+ PipelineSource<any>,
203
+ ...PipelineTransform<any, any>[],
204
+ PipelineDestination<any, any>,
205
+ options: PipelineOptions,
206
+ ]
86
207
  ): Promise<void>;
87
208
  }
88
- declare module "node:stream/promises" {
89
- export * from "stream/promises";
209
+ declare module "stream/promises" {
210
+ export * from "node:stream/promises";
90
211
  }