@types/node 20.7.1 → 20.8.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.
node/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Wed, 27 Sep 2023 20:35:06 GMT
11
+ * Last updated: Sat, 30 Sep 2023 08:35:04 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
14
14
 
node/buffer.d.ts CHANGED
@@ -71,7 +71,7 @@ declare module "buffer" {
71
71
  MAX_LENGTH: number;
72
72
  MAX_STRING_LENGTH: number;
73
73
  };
74
- export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary";
74
+ export type TranscodeEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "utf-16le" | "ucs2" | "ucs-2" | "latin1" | "binary";
75
75
  /**
76
76
  * Re-encodes the given `Buffer` or `Uint8Array` instance from one character
77
77
  * encoding to another. Returns a new `Buffer` instance.
@@ -225,6 +225,7 @@ declare module "buffer" {
225
225
  | "utf8"
226
226
  | "utf-8"
227
227
  | "utf16le"
228
+ | "utf-16le"
228
229
  | "ucs2"
229
230
  | "ucs-2"
230
231
  | "base64"
node/crypto.d.ts CHANGED
@@ -260,7 +260,7 @@ declare module "crypto" {
260
260
  function createHmac(algorithm: string, key: BinaryLike | KeyObject, options?: stream.TransformOptions): Hmac;
261
261
  // https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
262
262
  type BinaryToTextEncoding = "base64" | "base64url" | "hex" | "binary";
263
- type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "latin1";
263
+ type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "utf-16le" | "latin1";
264
264
  type LegacyCharacterEncoding = "ascii" | "binary" | "ucs2" | "ucs-2";
265
265
  type Encoding = BinaryToTextEncoding | CharacterEncoding | LegacyCharacterEncoding;
266
266
  type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
node/http.d.ts CHANGED
@@ -113,7 +113,87 @@ declare module "http" {
113
113
  }
114
114
  // outgoing headers allows numbers (as they are converted internally to strings)
115
115
  type OutgoingHttpHeader = number | string | string[];
116
- interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {}
116
+ interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {
117
+ accept?: string | string[] | undefined;
118
+ 'accept-charset'?: string | string[] | undefined;
119
+ 'accept-encoding'?: string | string[] | undefined;
120
+ 'accept-language'?: string | string[] | undefined;
121
+ 'accept-ranges'?: string | undefined;
122
+ 'access-control-allow-credentials'?: string | undefined;
123
+ 'access-control-allow-headers'?: string | undefined;
124
+ 'access-control-allow-methods'?: string | undefined;
125
+ 'access-control-allow-origin'?: string | undefined;
126
+ 'access-control-expose-headers'?: string | undefined;
127
+ 'access-control-max-age'?: string | undefined;
128
+ 'access-control-request-headers'?: string | undefined;
129
+ 'access-control-request-method'?: string | undefined;
130
+ age?: string | undefined;
131
+ allow?: string | undefined;
132
+ authorization?: string | undefined;
133
+ 'cache-control'?: string | undefined;
134
+ 'cdn-cache-control'?: string | undefined;
135
+ connection?: string | string[] | undefined;
136
+ 'content-disposition'?: string | undefined;
137
+ 'content-encoding'?: string | undefined;
138
+ 'content-language'?: string | undefined;
139
+ 'content-length'?: string | number | undefined;
140
+ 'content-location'?: string | undefined;
141
+ 'content-range'?: string | undefined;
142
+ 'content-security-policy'?: string | undefined;
143
+ 'content-security-policy-report-only'?: string | undefined;
144
+ cookie?: string | string[] | undefined;
145
+ dav?: string | string[] | undefined;
146
+ dnt?: string | undefined;
147
+ date?: string | undefined;
148
+ etag?: string | undefined;
149
+ expect?: string | undefined;
150
+ expires?: string | undefined;
151
+ forwarded?: string | undefined;
152
+ from?: string | undefined;
153
+ host?: string | undefined;
154
+ 'if-match'?: string | undefined;
155
+ 'if-modified-since'?: string | undefined;
156
+ 'if-none-match'?: string | undefined;
157
+ 'if-range'?: string | undefined;
158
+ 'if-unmodified-since'?: string | undefined;
159
+ 'last-modified'?: string | undefined;
160
+ link?: string | string[] | undefined;
161
+ location?: string | undefined;
162
+ 'max-forwards'?: string | undefined;
163
+ origin?: string | undefined;
164
+ prgama?: string | string[] | undefined;
165
+ 'proxy-authenticate'?: string | string[] | undefined;
166
+ 'proxy-authorization'?: string | undefined;
167
+ 'public-key-pins'?: string | undefined;
168
+ 'public-key-pins-report-only'?: string | undefined;
169
+ range?: string | undefined;
170
+ referer?: string | undefined;
171
+ 'referrer-policy'?: string | undefined;
172
+ refresh?: string | undefined;
173
+ 'retry-after'?: string | undefined;
174
+ 'sec-websocket-accept'?: string | undefined;
175
+ 'sec-websocket-extensions'?: string | string[] | undefined;
176
+ 'sec-websocket-key'?: string | undefined;
177
+ 'sec-websocket-protocol'?: string | string[] | undefined;
178
+ 'sec-websocket-version'?: string | undefined;
179
+ server?: string | undefined;
180
+ 'set-cookie'?: string | string[] | undefined;
181
+ 'strict-transport-security'?: string | undefined;
182
+ te?: string | undefined;
183
+ trailer?: string | undefined;
184
+ 'transfer-encoding'?: string | undefined;
185
+ 'user-agent'?: string | undefined;
186
+ upgrade?: string | undefined;
187
+ 'upgrade-insecure-requests'?: string | undefined;
188
+ vary?: string | undefined;
189
+ via?: string | string[] | undefined;
190
+ warning?: string | undefined;
191
+ 'www-authenticate'?: string | string[] | undefined;
192
+ 'x-content-type-options'?: string | undefined;
193
+ 'x-dns-prefetch-control'?: string | undefined;
194
+ 'x-frame-options'?: string | undefined;
195
+ 'x-xss-protection'?: string | undefined;
196
+ }
117
197
  interface ClientRequestArgs {
118
198
  _defaultAgent?: Agent | undefined;
119
199
  agent?: Agent | boolean | undefined;
@@ -343,21 +423,21 @@ declare module "http" {
343
423
  */
344
424
  closeIdleConnections(): void;
345
425
  addListener(event: string, listener: (...args: any[]) => void): this;
346
- addListener(event: "close", listener: () => void): this;
347
- addListener(event: "connection", listener: (socket: Socket) => void): this;
348
- addListener(event: "error", listener: (err: Error) => void): this;
349
- addListener(event: "listening", listener: () => void): this;
350
- addListener(event: "checkContinue", listener: RequestListener<Request, Response>): this;
351
- addListener(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
352
- addListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
426
+ addListener(event: 'close', listener: () => void): this;
427
+ addListener(event: 'connection', listener: (socket: Socket) => void): this;
428
+ addListener(event: 'error', listener: (err: Error) => void): this;
429
+ addListener(event: 'listening', listener: () => void): this;
430
+ addListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
431
+ addListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
432
+ addListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
353
433
  addListener(
354
- event: "connect",
434
+ event: 'connect',
355
435
  listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
356
436
  ): this;
357
- addListener(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
358
- addListener(event: "request", listener: RequestListener<Request, Response>): this;
437
+ addListener(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
438
+ addListener(event: 'request', listener: RequestListener<Request, Response>): this;
359
439
  addListener(
360
- event: "upgrade",
440
+ event: 'upgrade',
361
441
  listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
362
442
  ): this;
363
443
  emit(event: string, ...args: any[]): boolean;
@@ -397,63 +477,63 @@ declare module "http" {
397
477
  on(event: "request", listener: RequestListener<Request, Response>): this;
398
478
  on(event: "upgrade", listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
399
479
  once(event: string, listener: (...args: any[]) => void): this;
400
- once(event: "close", listener: () => void): this;
401
- once(event: "connection", listener: (socket: Socket) => void): this;
402
- once(event: "error", listener: (err: Error) => void): this;
403
- once(event: "listening", listener: () => void): this;
404
- once(event: "checkContinue", listener: RequestListener<Request, Response>): this;
405
- once(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
406
- once(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
480
+ once(event: 'close', listener: () => void): this;
481
+ once(event: 'connection', listener: (socket: Socket) => void): this;
482
+ once(event: 'error', listener: (err: Error) => void): this;
483
+ once(event: 'listening', listener: () => void): this;
484
+ once(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
485
+ once(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
486
+ once(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
407
487
  once(
408
- event: "connect",
488
+ event: 'connect',
409
489
  listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
410
490
  ): this;
411
- once(event: "dropRequest", listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
412
- once(event: "request", listener: RequestListener<Request, Response>): this;
491
+ once(event: 'dropRequest', listener: (req: InstanceType<Request>, socket: stream.Duplex) => void): this;
492
+ once(event: 'request', listener: RequestListener<Request, Response>): this;
413
493
  once(
414
- event: "upgrade",
494
+ event: 'upgrade',
415
495
  listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
416
496
  ): this;
417
497
  prependListener(event: string, listener: (...args: any[]) => void): this;
418
- prependListener(event: "close", listener: () => void): this;
419
- prependListener(event: "connection", listener: (socket: Socket) => void): this;
420
- prependListener(event: "error", listener: (err: Error) => void): this;
421
- prependListener(event: "listening", listener: () => void): this;
422
- prependListener(event: "checkContinue", listener: RequestListener<Request, Response>): this;
423
- prependListener(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
424
- prependListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
498
+ prependListener(event: 'close', listener: () => void): this;
499
+ prependListener(event: 'connection', listener: (socket: Socket) => void): this;
500
+ prependListener(event: 'error', listener: (err: Error) => void): this;
501
+ prependListener(event: 'listening', listener: () => void): this;
502
+ prependListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
503
+ prependListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
504
+ prependListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
425
505
  prependListener(
426
- event: "connect",
506
+ event: 'connect',
427
507
  listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
428
508
  ): this;
429
509
  prependListener(
430
- event: "dropRequest",
510
+ event: 'dropRequest',
431
511
  listener: (req: InstanceType<Request>, socket: stream.Duplex) => void,
432
512
  ): this;
433
- prependListener(event: "request", listener: RequestListener<Request, Response>): this;
513
+ prependListener(event: 'request', listener: RequestListener<Request, Response>): this;
434
514
  prependListener(
435
- event: "upgrade",
515
+ event: 'upgrade',
436
516
  listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
437
517
  ): this;
438
518
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
439
- prependOnceListener(event: "close", listener: () => void): this;
440
- prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
441
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
442
- prependOnceListener(event: "listening", listener: () => void): this;
443
- prependOnceListener(event: "checkContinue", listener: RequestListener<Request, Response>): this;
444
- prependOnceListener(event: "checkExpectation", listener: RequestListener<Request, Response>): this;
445
- prependOnceListener(event: "clientError", listener: (err: Error, socket: stream.Duplex) => void): this;
519
+ prependOnceListener(event: 'close', listener: () => void): this;
520
+ prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
521
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
522
+ prependOnceListener(event: 'listening', listener: () => void): this;
523
+ prependOnceListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
524
+ prependOnceListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
525
+ prependOnceListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
446
526
  prependOnceListener(
447
- event: "connect",
527
+ event: 'connect',
448
528
  listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
449
529
  ): this;
450
530
  prependOnceListener(
451
- event: "dropRequest",
531
+ event: 'dropRequest',
452
532
  listener: (req: InstanceType<Request>, socket: stream.Duplex) => void,
453
533
  ): this;
454
- prependOnceListener(event: "request", listener: RequestListener<Request, Response>): this;
534
+ prependOnceListener(event: 'request', listener: RequestListener<Request, Response>): this;
455
535
  prependOnceListener(
456
- event: "upgrade",
536
+ event: 'upgrade',
457
537
  listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
458
538
  ): this;
459
539
  }
@@ -935,26 +1015,26 @@ declare module "http" {
935
1015
  /**
936
1016
  * @deprecated
937
1017
  */
938
- addListener(event: "abort", listener: () => void): this;
1018
+ addListener(event: 'abort', listener: () => void): this;
939
1019
  addListener(
940
- event: "connect",
1020
+ event: 'connect',
941
1021
  listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
942
1022
  ): this;
943
- addListener(event: "continue", listener: () => void): this;
944
- addListener(event: "information", listener: (info: InformationEvent) => void): this;
945
- addListener(event: "response", listener: (response: IncomingMessage) => void): this;
946
- addListener(event: "socket", listener: (socket: Socket) => void): this;
947
- addListener(event: "timeout", listener: () => void): this;
1023
+ addListener(event: 'continue', listener: () => void): this;
1024
+ addListener(event: 'information', listener: (info: InformationEvent) => void): this;
1025
+ addListener(event: 'response', listener: (response: IncomingMessage) => void): this;
1026
+ addListener(event: 'socket', listener: (socket: Socket) => void): this;
1027
+ addListener(event: 'timeout', listener: () => void): this;
948
1028
  addListener(
949
- event: "upgrade",
1029
+ event: 'upgrade',
950
1030
  listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
951
1031
  ): this;
952
- addListener(event: "close", listener: () => void): this;
953
- addListener(event: "drain", listener: () => void): this;
954
- addListener(event: "error", listener: (err: Error) => void): this;
955
- addListener(event: "finish", listener: () => void): this;
956
- addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
957
- addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
1032
+ addListener(event: 'close', listener: () => void): this;
1033
+ addListener(event: 'drain', listener: () => void): this;
1034
+ addListener(event: 'error', listener: (err: Error) => void): this;
1035
+ addListener(event: 'finish', listener: () => void): this;
1036
+ addListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
1037
+ addListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
958
1038
  addListener(event: string | symbol, listener: (...args: any[]) => void): this;
959
1039
  /**
960
1040
  * @deprecated
@@ -995,50 +1075,50 @@ declare module "http" {
995
1075
  /**
996
1076
  * @deprecated
997
1077
  */
998
- prependListener(event: "abort", listener: () => void): this;
1078
+ prependListener(event: 'abort', listener: () => void): this;
999
1079
  prependListener(
1000
- event: "connect",
1080
+ event: 'connect',
1001
1081
  listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1002
1082
  ): this;
1003
- prependListener(event: "continue", listener: () => void): this;
1004
- prependListener(event: "information", listener: (info: InformationEvent) => void): this;
1005
- prependListener(event: "response", listener: (response: IncomingMessage) => void): this;
1006
- prependListener(event: "socket", listener: (socket: Socket) => void): this;
1007
- prependListener(event: "timeout", listener: () => void): this;
1083
+ prependListener(event: 'continue', listener: () => void): this;
1084
+ prependListener(event: 'information', listener: (info: InformationEvent) => void): this;
1085
+ prependListener(event: 'response', listener: (response: IncomingMessage) => void): this;
1086
+ prependListener(event: 'socket', listener: (socket: Socket) => void): this;
1087
+ prependListener(event: 'timeout', listener: () => void): this;
1008
1088
  prependListener(
1009
- event: "upgrade",
1089
+ event: 'upgrade',
1010
1090
  listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1011
1091
  ): this;
1012
- prependListener(event: "close", listener: () => void): this;
1013
- prependListener(event: "drain", listener: () => void): this;
1014
- prependListener(event: "error", listener: (err: Error) => void): this;
1015
- prependListener(event: "finish", listener: () => void): this;
1016
- prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
1017
- prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
1092
+ prependListener(event: 'close', listener: () => void): this;
1093
+ prependListener(event: 'drain', listener: () => void): this;
1094
+ prependListener(event: 'error', listener: (err: Error) => void): this;
1095
+ prependListener(event: 'finish', listener: () => void): this;
1096
+ prependListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
1097
+ prependListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
1018
1098
  prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
1019
1099
  /**
1020
1100
  * @deprecated
1021
1101
  */
1022
- prependOnceListener(event: "abort", listener: () => void): this;
1102
+ prependOnceListener(event: 'abort', listener: () => void): this;
1023
1103
  prependOnceListener(
1024
- event: "connect",
1104
+ event: 'connect',
1025
1105
  listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1026
1106
  ): this;
1027
- prependOnceListener(event: "continue", listener: () => void): this;
1028
- prependOnceListener(event: "information", listener: (info: InformationEvent) => void): this;
1029
- prependOnceListener(event: "response", listener: (response: IncomingMessage) => void): this;
1030
- prependOnceListener(event: "socket", listener: (socket: Socket) => void): this;
1031
- prependOnceListener(event: "timeout", listener: () => void): this;
1107
+ prependOnceListener(event: 'continue', listener: () => void): this;
1108
+ prependOnceListener(event: 'information', listener: (info: InformationEvent) => void): this;
1109
+ prependOnceListener(event: 'response', listener: (response: IncomingMessage) => void): this;
1110
+ prependOnceListener(event: 'socket', listener: (socket: Socket) => void): this;
1111
+ prependOnceListener(event: 'timeout', listener: () => void): this;
1032
1112
  prependOnceListener(
1033
- event: "upgrade",
1113
+ event: 'upgrade',
1034
1114
  listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
1035
1115
  ): this;
1036
- prependOnceListener(event: "close", listener: () => void): this;
1037
- prependOnceListener(event: "drain", listener: () => void): this;
1038
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
1039
- prependOnceListener(event: "finish", listener: () => void): this;
1040
- prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
1041
- prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
1116
+ prependOnceListener(event: 'close', listener: () => void): this;
1117
+ prependOnceListener(event: 'drain', listener: () => void): this;
1118
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
1119
+ prependOnceListener(event: 'finish', listener: () => void): this;
1120
+ prependOnceListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
1121
+ prependOnceListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
1042
1122
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
1043
1123
  }
1044
1124
  /**
node/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for non-npm package Node.js 20.7
1
+ // Type definitions for non-npm package Node.js 20.8
2
2
  // Project: https://nodejs.org/
3
3
  // Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
4
4
  // DefinitelyTyped <https://github.com/DefinitelyTyped>
node/module.d.ts CHANGED
@@ -142,13 +142,13 @@ declare module "module" {
142
142
  */
143
143
  type GlobalPreloadHook = (context: GlobalPreloadContext) => string;
144
144
  /**
145
- * The `initialize` hook provides a way to define a custom function that runs in the loader's thread
146
- * when the loader is initialized. Initialization happens when the loader is registered via `register`
147
- * or registered via the `--experimental-loader` command line option.
145
+ * The `initialize` hook provides a way to define a custom function that runs in the hooks thread
146
+ * when the hooks module is initialized. Initialization happens when the hooks module is registered via `register`.
148
147
  *
149
- * This hook can send and receive data from a `register` invocation, including ports and other transferrable objects.
148
+ * This hook can receive data from a `register` invocation, including ports and other transferrable objects.
149
+ * The return value of `initialize` can be a `Promise`, in which case it will be awaited before the main application thread execution resumes.
150
150
  */
151
- type InitializeHook<Data = any, ReturnType = any> = (data: Data) => ReturnType;
151
+ type InitializeHook<Data = any> = (data: Data) => void | Promise<void>;
152
152
  interface ResolveHookContext {
153
153
  /**
154
154
  * Export conditions of the relevant `package.json`
@@ -240,7 +240,7 @@ declare module "module" {
240
240
  ) => LoadFnOutput | Promise<LoadFnOutput>;
241
241
  }
242
242
  interface RegisterOptions<Data> {
243
- parentURL: string;
243
+ parentURL: string | URL;
244
244
  data?: Data | undefined;
245
245
  transferList?: any[] | undefined;
246
246
  }
@@ -252,12 +252,12 @@ declare module "module" {
252
252
  static builtinModules: string[];
253
253
  static isBuiltin(moduleName: string): boolean;
254
254
  static Module: typeof Module;
255
- static register<Data = any, ReturnType = any>(
256
- specifier: string,
257
- parentURL?: string,
255
+ static register<Data = any>(
256
+ specifier: string | URL,
257
+ parentURL?: string | URL,
258
258
  options?: RegisterOptions<Data>,
259
- ): ReturnType;
260
- static register<Data = any, ReturnType = any>(specifier: string, options?: RegisterOptions<Data>): ReturnType;
259
+ ): void;
260
+ static register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void;
261
261
  constructor(id: string, parent?: Module);
262
262
  }
263
263
  global {
node/net.d.ts CHANGED
@@ -240,6 +240,7 @@ declare module "net" {
240
240
  *
241
241
  * Each address is a string in the form of `$IP:$PORT`.
242
242
  * If the connection was successful, then the last address is the one that the socket is currently connected to.
243
+ * @since v19.4.0
243
244
  */
244
245
  readonly autoSelectFamilyAttemptedAddresses: string[];
245
246
  /**
@@ -832,9 +833,27 @@ declare module "net" {
832
833
  function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
833
834
  function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
834
835
  function createConnection(path: string, connectionListener?: () => void): Socket;
836
+ /**
837
+ * Gets the current default value of the `autoSelectFamily` option of `socket.connect(options)`.
838
+ * The initial default value is `true`, unless the command line option`--no-network-family-autoselection` is provided.
839
+ * @since v19.4.0
840
+ */
835
841
  function getDefaultAutoSelectFamily(): boolean;
842
+ /**
843
+ * Sets the default value of the `autoSelectFamily` option of `socket.connect(options)`.
844
+ * @since v19.4.0
845
+ */
836
846
  function setDefaultAutoSelectFamily(value: boolean): void;
847
+ /**
848
+ * Gets the current default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`.
849
+ * The initial default value is `250`.
850
+ * @since v19.8.0
851
+ */
837
852
  function getDefaultAutoSelectFamilyAttemptTimeout(): number;
853
+ /**
854
+ * Sets the default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`.
855
+ * @since v19.8.0
856
+ */
838
857
  function setDefaultAutoSelectFamilyAttemptTimeout(value: number): void;
839
858
  /**
840
859
  * Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4
node/os.d.ts CHANGED
@@ -400,7 +400,7 @@ declare module "os" {
400
400
  const EOL: string;
401
401
  /**
402
402
  * Returns the operating system CPU architecture for which the Node.js binary was
403
- * compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, and `'x64'`.
403
+ * compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
404
404
  *
405
405
  * The return value is equivalent to `process.arch`.
406
406
  * @since v0.5.0
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "20.7.1",
3
+ "version": "20.8.0",
4
4
  "description": "TypeScript definitions for Node.js",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -227,6 +227,6 @@
227
227
  },
228
228
  "scripts": {},
229
229
  "dependencies": {},
230
- "typesPublisherContentHash": "4619e9f05c4b3ece54c50232ef1f73d47265431ca489080efc47c46a264555da",
230
+ "typesPublisherContentHash": "7637ed07b3e4b1806d0b4b3e38bd788c3004f33c9700b8b65432d5894164b46f",
231
231
  "typeScriptVersion": "4.5"
232
232
  }
node/stream/web.d.ts CHANGED
@@ -77,6 +77,15 @@ declare module "stream/web" {
77
77
  type ReadableStreamDefaultReadResult<T> =
78
78
  | ReadableStreamDefaultReadValueResult<T>
79
79
  | ReadableStreamDefaultReadDoneResult;
80
+ interface ReadableStreamReadValueResult<T> {
81
+ done: false;
82
+ value: T;
83
+ }
84
+ interface ReadableStreamReadDoneResult<T> {
85
+ done: true;
86
+ value?: T;
87
+ }
88
+ type ReadableStreamReadResult<T> = ReadableStreamReadValueResult<T> | ReadableStreamReadDoneResult<T>;
80
89
  interface ReadableByteStreamControllerCallback {
81
90
  (controller: ReadableByteStreamController): void | PromiseLike<void>;
82
91
  }
@@ -138,6 +147,7 @@ declare module "stream/web" {
138
147
  readonly locked: boolean;
139
148
  cancel(reason?: any): Promise<void>;
140
149
  getReader(): ReadableStreamDefaultReader<R>;
150
+ getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
141
151
  pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
142
152
  pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
143
153
  tee(): [ReadableStream<R>, ReadableStream<R>];
@@ -153,6 +163,10 @@ declare module "stream/web" {
153
163
  read(): Promise<ReadableStreamDefaultReadResult<R>>;
154
164
  releaseLock(): void;
155
165
  }
166
+ interface ReadableStreamBYOBReader extends ReadableStreamGenericReader {
167
+ read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
168
+ releaseLock(): void;
169
+ }
156
170
  const ReadableStreamDefaultReader: {
157
171
  prototype: ReadableStreamDefaultReader;
158
172
  new<R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
node/test.d.ts CHANGED
@@ -84,7 +84,9 @@ declare module "node:test" {
84
84
  /**
85
85
  * ```js
86
86
  * import { tap } from 'node:test/reporters';
87
+ * import { run } from 'node:test';
87
88
  * import process from 'node:process';
89
+ * import path from 'node:path';
88
90
  *
89
91
  * run({ files: [path.resolve('./tests/test.js')] })
90
92
  * .compose(tap)
@@ -292,6 +294,10 @@ declare module "node:test" {
292
294
  * For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run.
293
295
  */
294
296
  testNamePatterns?: string | RegExp | string[] | RegExp[];
297
+ /**
298
+ * If truthy, the test context will only run tests that have the `only` option set
299
+ */
300
+ only?: boolean;
295
301
  /**
296
302
  * A function that accepts the TestsStream instance and can be used to setup listeners before any tests are run.
297
303
  */
@@ -1368,5 +1374,9 @@ declare module "node:test/reporters" {
1368
1374
  class Spec extends Transform {
1369
1375
  constructor();
1370
1376
  }
1371
- export { dot, Spec as spec, tap, TestEvent };
1377
+ /**
1378
+ * The `junit` reporter outputs test results in a jUnit XML format
1379
+ */
1380
+ function junit(source: TestEventGenerator): AsyncGenerator<string, void>;
1381
+ export { dot, Spec as spec, tap, junit, TestEvent };
1372
1382
  }
node/ts4.8/buffer.d.ts CHANGED
@@ -71,7 +71,7 @@ declare module "buffer" {
71
71
  MAX_LENGTH: number;
72
72
  MAX_STRING_LENGTH: number;
73
73
  };
74
- export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary";
74
+ export type TranscodeEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "utf-16le" | "ucs2" | "ucs-2" | "latin1" | "binary";
75
75
  /**
76
76
  * Re-encodes the given `Buffer` or `Uint8Array` instance from one character
77
77
  * encoding to another. Returns a new `Buffer` instance.
@@ -225,6 +225,7 @@ declare module "buffer" {
225
225
  | "utf8"
226
226
  | "utf-8"
227
227
  | "utf16le"
228
+ | "utf-16le"
228
229
  | "ucs2"
229
230
  | "ucs-2"
230
231
  | "base64"
@@ -529,7 +530,7 @@ declare module "buffer" {
529
530
  * @param [fill=0] A value to pre-fill the new `Buffer` with.
530
531
  * @param [encoding='utf8'] If `fill` is a string, this is its encoding.
531
532
  */
532
- alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
533
+ alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer;
533
534
  /**
534
535
  * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
535
536
  *
node/ts4.8/crypto.d.ts CHANGED
@@ -260,7 +260,7 @@ declare module "crypto" {
260
260
  function createHmac(algorithm: string, key: BinaryLike | KeyObject, options?: stream.TransformOptions): Hmac;
261
261
  // https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
262
262
  type BinaryToTextEncoding = "base64" | "base64url" | "hex" | "binary";
263
- type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "latin1";
263
+ type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "utf-16le" | "latin1";
264
264
  type LegacyCharacterEncoding = "ascii" | "binary" | "ucs2" | "ucs-2";
265
265
  type Encoding = BinaryToTextEncoding | CharacterEncoding | LegacyCharacterEncoding;
266
266
  type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
node/ts4.8/http.d.ts CHANGED
@@ -113,7 +113,87 @@ declare module "http" {
113
113
  }
114
114
  // outgoing headers allows numbers (as they are converted internally to strings)
115
115
  type OutgoingHttpHeader = number | string | string[];
116
- interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {}
116
+ interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {
117
+ accept?: string | string[] | undefined;
118
+ 'accept-charset'?: string | string[] | undefined;
119
+ 'accept-encoding'?: string | string[] | undefined;
120
+ 'accept-language'?: string | string[] | undefined;
121
+ 'accept-ranges'?: string | undefined;
122
+ 'access-control-allow-credentials'?: string | undefined;
123
+ 'access-control-allow-headers'?: string | undefined;
124
+ 'access-control-allow-methods'?: string | undefined;
125
+ 'access-control-allow-origin'?: string | undefined;
126
+ 'access-control-expose-headers'?: string | undefined;
127
+ 'access-control-max-age'?: string | undefined;
128
+ 'access-control-request-headers'?: string | undefined;
129
+ 'access-control-request-method'?: string | undefined;
130
+ age?: string | undefined;
131
+ allow?: string | undefined;
132
+ authorization?: string | undefined;
133
+ 'cache-control'?: string | undefined;
134
+ 'cdn-cache-control'?: string | undefined;
135
+ connection?: string | string[] | undefined;
136
+ 'content-disposition'?: string | undefined;
137
+ 'content-encoding'?: string | undefined;
138
+ 'content-language'?: string | undefined;
139
+ 'content-length'?: string | number | undefined;
140
+ 'content-location'?: string | undefined;
141
+ 'content-range'?: string | undefined;
142
+ 'content-security-policy'?: string | undefined;
143
+ 'content-security-policy-report-only'?: string | undefined;
144
+ cookie?: string | string[] | undefined;
145
+ dav?: string | string[] | undefined;
146
+ dnt?: string | undefined;
147
+ date?: string | undefined;
148
+ etag?: string | undefined;
149
+ expect?: string | undefined;
150
+ expires?: string | undefined;
151
+ forwarded?: string | undefined;
152
+ from?: string | undefined;
153
+ host?: string | undefined;
154
+ 'if-match'?: string | undefined;
155
+ 'if-modified-since'?: string | undefined;
156
+ 'if-none-match'?: string | undefined;
157
+ 'if-range'?: string | undefined;
158
+ 'if-unmodified-since'?: string | undefined;
159
+ 'last-modified'?: string | undefined;
160
+ link?: string | string[] | undefined;
161
+ location?: string | undefined;
162
+ 'max-forwards'?: string | undefined;
163
+ origin?: string | undefined;
164
+ prgama?: string | string[] | undefined;
165
+ 'proxy-authenticate'?: string | string[] | undefined;
166
+ 'proxy-authorization'?: string | undefined;
167
+ 'public-key-pins'?: string | undefined;
168
+ 'public-key-pins-report-only'?: string | undefined;
169
+ range?: string | undefined;
170
+ referer?: string | undefined;
171
+ 'referrer-policy'?: string | undefined;
172
+ refresh?: string | undefined;
173
+ 'retry-after'?: string | undefined;
174
+ 'sec-websocket-accept'?: string | undefined;
175
+ 'sec-websocket-extensions'?: string | string[] | undefined;
176
+ 'sec-websocket-key'?: string | undefined;
177
+ 'sec-websocket-protocol'?: string | string[] | undefined;
178
+ 'sec-websocket-version'?: string | undefined;
179
+ server?: string | undefined;
180
+ 'set-cookie'?: string | string[] | undefined;
181
+ 'strict-transport-security'?: string | undefined;
182
+ te?: string | undefined;
183
+ trailer?: string | undefined;
184
+ 'transfer-encoding'?: string | undefined;
185
+ 'user-agent'?: string | undefined;
186
+ upgrade?: string | undefined;
187
+ 'upgrade-insecure-requests'?: string | undefined;
188
+ vary?: string | undefined;
189
+ via?: string | string[] | undefined;
190
+ warning?: string | undefined;
191
+ 'www-authenticate'?: string | string[] | undefined;
192
+ 'x-content-type-options'?: string | undefined;
193
+ 'x-dns-prefetch-control'?: string | undefined;
194
+ 'x-frame-options'?: string | undefined;
195
+ 'x-xss-protection'?: string | undefined;
196
+ }
117
197
  interface ClientRequestArgs {
118
198
  _defaultAgent?: Agent | undefined;
119
199
  agent?: Agent | boolean | undefined;
node/ts4.8/module.d.ts CHANGED
@@ -65,6 +65,24 @@ declare module "module" {
65
65
  originalLine: number;
66
66
  originalColumn: number;
67
67
  }
68
+ interface SourceOrigin {
69
+ /**
70
+ * The name of the range in the source map, if one was provided
71
+ */
72
+ name?: string;
73
+ /**
74
+ * The file name of the original source, as reported in the SourceMap
75
+ */
76
+ fileName: string;
77
+ /**
78
+ * The 1-indexed lineNumber of the corresponding call site in the original source
79
+ */
80
+ lineNumber: number;
81
+ /**
82
+ * The 1-indexed columnNumber of the corresponding call site in the original source
83
+ */
84
+ columnNumber: number;
85
+ }
68
86
  /**
69
87
  * @since v13.7.0, v12.17.0
70
88
  */
@@ -93,6 +111,16 @@ declare module "module" {
93
111
  * @param columnOffset The zero-indexed column number offset in the generated source
94
112
  */
95
113
  findEntry(lineOffset: number, columnOffset: number): SourceMapping;
114
+ /**
115
+ * Given a 1-indexed `lineNumber` and `columnNumber` from a call site in the generated source,
116
+ * find the corresponding call site location in the original source.
117
+ *
118
+ * If the `lineNumber` and `columnNumber` provided are not found in any source map,
119
+ * then an empty object is returned.
120
+ * @param lineNumber The 1-indexed line number of the call site in the generated source
121
+ * @param columnNumber The 1-indexed column number of the call site in the generated source
122
+ */
123
+ findOrigin(lineNumber: number, columnNumber: number): SourceOrigin | {};
96
124
  }
97
125
  interface ImportAssertions extends NodeJS.Dict<string> {
98
126
  type?: string | undefined;
@@ -114,13 +142,13 @@ declare module "module" {
114
142
  */
115
143
  type GlobalPreloadHook = (context: GlobalPreloadContext) => string;
116
144
  /**
117
- * The `initialize` hook provides a way to define a custom function that runs in the loader's thread
118
- * when the loader is initialized. Initialization happens when the loader is registered via `register`
119
- * or registered via the `--experimental-loader` command line option.
145
+ * The `initialize` hook provides a way to define a custom function that runs in the hooks thread
146
+ * when the hooks module is initialized. Initialization happens when the hooks module is registered via `register`.
120
147
  *
121
- * This hook can send and receive data from a `register` invocation, including ports and other transferrable objects.
148
+ * This hook can receive data from a `register` invocation, including ports and other transferrable objects.
149
+ * The return value of `initialize` can be a `Promise`, in which case it will be awaited before the main application thread execution resumes.
122
150
  */
123
- type InitializeHook<Data = any, ReturnType = any> = (data: Data) => ReturnType;
151
+ type InitializeHook<Data = any> = (data: Data) => void | Promise<void>;
124
152
  interface ResolveHookContext {
125
153
  /**
126
154
  * Export conditions of the relevant `package.json`
@@ -212,7 +240,7 @@ declare module "module" {
212
240
  ) => LoadFnOutput | Promise<LoadFnOutput>;
213
241
  }
214
242
  interface RegisterOptions<Data> {
215
- parentURL: string;
243
+ parentURL: string | URL;
216
244
  data?: Data | undefined;
217
245
  transferList?: any[] | undefined;
218
246
  }
@@ -224,12 +252,12 @@ declare module "module" {
224
252
  static builtinModules: string[];
225
253
  static isBuiltin(moduleName: string): boolean;
226
254
  static Module: typeof Module;
227
- static register<Data = any, ReturnType = any>(
228
- specifier: string,
229
- parentURL?: string,
255
+ static register<Data = any>(
256
+ specifier: string | URL,
257
+ parentURL?: string | URL,
230
258
  options?: RegisterOptions<Data>,
231
- ): ReturnType;
232
- static register<Data = any, ReturnType = any>(specifier: string, options?: RegisterOptions<Data>): ReturnType;
259
+ ): void;
260
+ static register<Data = any>(specifier: string | URL, options?: RegisterOptions<Data>): void;
233
261
  constructor(id: string, parent?: Module);
234
262
  }
235
263
  global {
node/ts4.8/net.d.ts CHANGED
@@ -234,6 +234,15 @@ declare module "net" {
234
234
  * @return The socket itself.
235
235
  */
236
236
  ref(): this;
237
+ /**
238
+ * This property is only present if the family autoselection algorithm is enabled in `socket.connect(options)`
239
+ * and it is an array of the addresses that have been attempted.
240
+ *
241
+ * Each address is a string in the form of `$IP:$PORT`.
242
+ * If the connection was successful, then the last address is the one that the socket is currently connected to.
243
+ * @since v19.4.0
244
+ */
245
+ readonly autoSelectFamilyAttemptedAddresses: string[];
237
246
  /**
238
247
  * This property shows the number of characters buffered for writing. The buffer
239
248
  * may contain strings whose length after encoding is not yet known. So this number
@@ -824,6 +833,28 @@ declare module "net" {
824
833
  function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
825
834
  function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
826
835
  function createConnection(path: string, connectionListener?: () => void): Socket;
836
+ /**
837
+ * Gets the current default value of the `autoSelectFamily` option of `socket.connect(options)`.
838
+ * The initial default value is `true`, unless the command line option`--no-network-family-autoselection` is provided.
839
+ * @since v19.4.0
840
+ */
841
+ function getDefaultAutoSelectFamily(): boolean;
842
+ /**
843
+ * Sets the default value of the `autoSelectFamily` option of `socket.connect(options)`.
844
+ * @since v19.4.0
845
+ */
846
+ function setDefaultAutoSelectFamily(value: boolean): void;
847
+ /**
848
+ * Gets the current default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`.
849
+ * The initial default value is `250`.
850
+ * @since v19.8.0
851
+ */
852
+ function getDefaultAutoSelectFamilyAttemptTimeout(): number;
853
+ /**
854
+ * Sets the default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`.
855
+ * @since v19.8.0
856
+ */
857
+ function setDefaultAutoSelectFamilyAttemptTimeout(value: number): void;
827
858
  /**
828
859
  * Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4
829
860
  * address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no leading zeroes. Otherwise, returns`0`.
node/ts4.8/os.d.ts CHANGED
@@ -400,7 +400,7 @@ declare module "os" {
400
400
  const EOL: string;
401
401
  /**
402
402
  * Returns the operating system CPU architecture for which the Node.js binary was
403
- * compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, and `'x64'`.
403
+ * compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
404
404
  *
405
405
  * The return value is equivalent to `process.arch`.
406
406
  * @since v0.5.0
@@ -77,6 +77,15 @@ declare module "stream/web" {
77
77
  type ReadableStreamDefaultReadResult<T> =
78
78
  | ReadableStreamDefaultReadValueResult<T>
79
79
  | ReadableStreamDefaultReadDoneResult;
80
+ interface ReadableStreamReadValueResult<T> {
81
+ done: false;
82
+ value: T;
83
+ }
84
+ interface ReadableStreamReadDoneResult<T> {
85
+ done: true;
86
+ value?: T;
87
+ }
88
+ type ReadableStreamReadResult<T> = ReadableStreamReadValueResult<T> | ReadableStreamReadDoneResult<T>;
80
89
  interface ReadableByteStreamControllerCallback {
81
90
  (controller: ReadableByteStreamController): void | PromiseLike<void>;
82
91
  }
@@ -138,6 +147,7 @@ declare module "stream/web" {
138
147
  readonly locked: boolean;
139
148
  cancel(reason?: any): Promise<void>;
140
149
  getReader(): ReadableStreamDefaultReader<R>;
150
+ getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
141
151
  pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
142
152
  pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
143
153
  tee(): [ReadableStream<R>, ReadableStream<R>];
@@ -153,6 +163,10 @@ declare module "stream/web" {
153
163
  read(): Promise<ReadableStreamDefaultReadResult<R>>;
154
164
  releaseLock(): void;
155
165
  }
166
+ interface ReadableStreamBYOBReader extends ReadableStreamGenericReader {
167
+ read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
168
+ releaseLock(): void;
169
+ }
156
170
  const ReadableStreamDefaultReader: {
157
171
  prototype: ReadableStreamDefaultReader;
158
172
  new<R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
node/ts4.8/stream.d.ts CHANGED
@@ -40,6 +40,12 @@ declare module "stream" {
40
40
  import Stream = internal.Stream;
41
41
  import Readable = internal.Readable;
42
42
  import ReadableOptions = internal.ReadableOptions;
43
+ interface ArrayOptions {
44
+ /** the maximum concurrent invocations of `fn` to call on the stream at once. **Default: 1**. */
45
+ concurrency?: number;
46
+ /** allows destroying the stream if the signal is aborted. */
47
+ signal?: AbortSignal;
48
+ }
43
49
  class ReadableBase extends Stream implements NodeJS.ReadableStream {
44
50
  /**
45
51
  * A utility method for creating Readable Streams out of iterators.
@@ -399,6 +405,164 @@ declare module "stream" {
399
405
  */
400
406
  wrap(stream: NodeJS.ReadableStream): this;
401
407
  push(chunk: any, encoding?: BufferEncoding): boolean;
408
+ /**
409
+ * The iterator created by this method gives users the option to cancel the destruction
410
+ * of the stream if the `for await...of` loop is exited by `return`, `break`, or `throw`,
411
+ * or if the iterator should destroy the stream if the stream emitted an error during iteration.
412
+ * @since v16.3.0
413
+ * @param options.destroyOnReturn When set to `false`, calling `return` on the async iterator,
414
+ * or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream.
415
+ * **Default: `true`**.
416
+ */
417
+ iterator(options?: { destroyOnReturn?: boolean }): AsyncIterableIterator<any>;
418
+ /**
419
+ * This method allows mapping over the stream. The *fn* function will be called for every chunk in the stream.
420
+ * If the *fn* function returns a promise - that promise will be `await`ed before being passed to the result stream.
421
+ * @since v17.4.0, v16.14.0
422
+ * @param fn a function to map over every chunk in the stream. Async or not.
423
+ * @returns a stream mapped with the function *fn*.
424
+ */
425
+ map(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => any, options?: ArrayOptions): Readable;
426
+ /**
427
+ * This method allows filtering the stream. For each chunk in the stream the *fn* function will be called
428
+ * and if it returns a truthy value, the chunk will be passed to the result stream.
429
+ * If the *fn* function returns a promise - that promise will be `await`ed.
430
+ * @since v17.4.0, v16.14.0
431
+ * @param fn a function to filter chunks from the stream. Async or not.
432
+ * @returns a stream filtered with the predicate *fn*.
433
+ */
434
+ filter(
435
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>,
436
+ options?: ArrayOptions,
437
+ ): Readable;
438
+ /**
439
+ * This method allows iterating a stream. For each chunk in the stream the *fn* function will be called.
440
+ * If the *fn* function returns a promise - that promise will be `await`ed.
441
+ *
442
+ * This method is different from `for await...of` loops in that it can optionally process chunks concurrently.
443
+ * In addition, a `forEach` iteration can only be stopped by having passed a `signal` option
444
+ * and aborting the related AbortController while `for await...of` can be stopped with `break` or `return`.
445
+ * In either case the stream will be destroyed.
446
+ *
447
+ * This method is different from listening to the `'data'` event in that it uses the `readable` event
448
+ * in the underlying machinary and can limit the number of concurrent *fn* calls.
449
+ * @since v17.5.0
450
+ * @param fn a function to call on each chunk of the stream. Async or not.
451
+ * @returns a promise for when the stream has finished.
452
+ */
453
+ forEach(
454
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => void | Promise<void>,
455
+ options?: ArrayOptions,
456
+ ): Promise<void>;
457
+ /**
458
+ * This method allows easily obtaining the contents of a stream.
459
+ *
460
+ * As this method reads the entire stream into memory, it negates the benefits of streams. It's intended
461
+ * for interoperability and convenience, not as the primary way to consume streams.
462
+ * @since v17.5.0
463
+ * @returns a promise containing an array with the contents of the stream.
464
+ */
465
+ toArray(options?: Pick<ArrayOptions, "signal">): Promise<any[]>;
466
+ /**
467
+ * This method is similar to `Array.prototype.some` and calls *fn* on each chunk in the stream
468
+ * until the awaited return value is `true` (or any truthy value). Once an *fn* call on a chunk
469
+ * `await`ed return value is truthy, the stream is destroyed and the promise is fulfilled with `true`.
470
+ * If none of the *fn* calls on the chunks return a truthy value, the promise is fulfilled with `false`.
471
+ * @since v17.5.0
472
+ * @param fn a function to call on each chunk of the stream. Async or not.
473
+ * @returns a promise evaluating to `true` if *fn* returned a truthy value for at least one of the chunks.
474
+ */
475
+ some(
476
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>,
477
+ options?: ArrayOptions,
478
+ ): Promise<boolean>;
479
+ /**
480
+ * This method is similar to `Array.prototype.find` and calls *fn* on each chunk in the stream
481
+ * to find a chunk with a truthy value for *fn*. Once an *fn* call's awaited return value is truthy,
482
+ * the stream is destroyed and the promise is fulfilled with value for which *fn* returned a truthy value.
483
+ * If all of the *fn* calls on the chunks return a falsy value, the promise is fulfilled with `undefined`.
484
+ * @since v17.5.0
485
+ * @param fn a function to call on each chunk of the stream. Async or not.
486
+ * @returns a promise evaluating to the first chunk for which *fn* evaluated with a truthy value,
487
+ * or `undefined` if no element was found.
488
+ */
489
+ find<T>(
490
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => data is T,
491
+ options?: ArrayOptions,
492
+ ): Promise<T | undefined>;
493
+ find(
494
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>,
495
+ options?: ArrayOptions,
496
+ ): Promise<any>;
497
+ /**
498
+ * This method is similar to `Array.prototype.every` and calls *fn* on each chunk in the stream
499
+ * to check if all awaited return values are truthy value for *fn*. Once an *fn* call on a chunk
500
+ * `await`ed return value is falsy, the stream is destroyed and the promise is fulfilled with `false`.
501
+ * If all of the *fn* calls on the chunks return a truthy value, the promise is fulfilled with `true`.
502
+ * @since v17.5.0
503
+ * @param fn a function to call on each chunk of the stream. Async or not.
504
+ * @returns a promise evaluating to `true` if *fn* returned a truthy value for every one of the chunks.
505
+ */
506
+ every(
507
+ fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>,
508
+ options?: ArrayOptions,
509
+ ): Promise<boolean>;
510
+ /**
511
+ * This method returns a new stream by applying the given callback to each chunk of the stream
512
+ * and then flattening the result.
513
+ *
514
+ * It is possible to return a stream or another iterable or async iterable from *fn* and the result streams
515
+ * will be merged (flattened) into the returned stream.
516
+ * @since v17.5.0
517
+ * @param fn a function to map over every chunk in the stream. May be async. May be a stream or generator.
518
+ * @returns a stream flat-mapped with the function *fn*.
519
+ */
520
+ flatMap(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => any, options?: ArrayOptions): Readable;
521
+ /**
522
+ * This method returns a new stream with the first *limit* chunks dropped from the start.
523
+ * @since v17.5.0
524
+ * @param limit the number of chunks to drop from the readable.
525
+ * @returns a stream with *limit* chunks dropped from the start.
526
+ */
527
+ drop(limit: number, options?: Pick<ArrayOptions, "signal">): Readable;
528
+ /**
529
+ * This method returns a new stream with the first *limit* chunks.
530
+ * @since v17.5.0
531
+ * @param limit the number of chunks to take from the readable.
532
+ * @returns a stream with *limit* chunks taken.
533
+ */
534
+ take(limit: number, options?: Pick<ArrayOptions, "signal">): Readable;
535
+ /**
536
+ * This method returns a new stream with chunks of the underlying stream paired with a counter
537
+ * in the form `[index, chunk]`. The first index value is `0` and it increases by 1 for each chunk produced.
538
+ * @since v17.5.0
539
+ * @returns a stream of indexed pairs.
540
+ */
541
+ asIndexedPairs(options?: Pick<ArrayOptions, "signal">): Readable;
542
+ /**
543
+ * This method calls *fn* on each chunk of the stream in order, passing it the result from the calculation
544
+ * on the previous element. It returns a promise for the final value of the reduction.
545
+ *
546
+ * If no *initial* value is supplied the first chunk of the stream is used as the initial value.
547
+ * If the stream is empty, the promise is rejected with a `TypeError` with the `ERR_INVALID_ARGS` code property.
548
+ *
549
+ * The reducer function iterates the stream element-by-element which means that there is no *concurrency* parameter
550
+ * or parallelism. To perform a reduce concurrently, you can extract the async function to `readable.map` method.
551
+ * @since v17.5.0
552
+ * @param fn a reducer function to call over every chunk in the stream. Async or not.
553
+ * @param initial the initial value to use in the reduction.
554
+ * @returns a promise for the final value of the reduction.
555
+ */
556
+ reduce<T = any>(
557
+ fn: (previous: any, data: any, options?: Pick<ArrayOptions, "signal">) => T,
558
+ initial?: undefined,
559
+ options?: Pick<ArrayOptions, "signal">,
560
+ ): Promise<T>;
561
+ reduce<T = any>(
562
+ fn: (previous: T, data: any, options?: Pick<ArrayOptions, "signal">) => T,
563
+ initial: T,
564
+ options?: Pick<ArrayOptions, "signal">,
565
+ ): Promise<T>;
402
566
  _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
403
567
  /**
404
568
  * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the readable
node/ts4.8/test.d.ts CHANGED
@@ -76,7 +76,7 @@
76
76
  *
77
77
  * If any tests fail, the process exit code is set to `1`.
78
78
  * @since v18.0.0, v16.17.0
79
- * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/test.js)
79
+ * @see [source](https://github.com/nodejs/node/blob/v20.4.0/lib/test.js)
80
80
  */
81
81
  declare module "node:test" {
82
82
  import { Readable } from "node:stream";
@@ -84,7 +84,9 @@ declare module "node:test" {
84
84
  /**
85
85
  * ```js
86
86
  * import { tap } from 'node:test/reporters';
87
+ * import { run } from 'node:test';
87
88
  * import process from 'node:process';
89
+ * import path from 'node:path';
88
90
  *
89
91
  * run({ files: [path.resolve('./tests/test.js')] })
90
92
  * .compose(tap)
@@ -292,6 +294,10 @@ declare module "node:test" {
292
294
  * For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run.
293
295
  */
294
296
  testNamePatterns?: string | RegExp | string[] | RegExp[];
297
+ /**
298
+ * If truthy, the test context will only run tests that have the `only` option set
299
+ */
300
+ only?: boolean;
295
301
  /**
296
302
  * A function that accepts the TestsStream instance and can be used to setup listeners before any tests are run.
297
303
  */
@@ -1146,7 +1152,22 @@ declare module "node:test" {
1146
1152
  */
1147
1153
  [Symbol.dispose](): void;
1148
1154
  }
1149
- export { after, afterEach, before, beforeEach, describe, it, mock, only, run, skip, test, test as default, todo, Mock };
1155
+ export {
1156
+ after,
1157
+ afterEach,
1158
+ before,
1159
+ beforeEach,
1160
+ describe,
1161
+ it,
1162
+ Mock,
1163
+ mock,
1164
+ only,
1165
+ run,
1166
+ skip,
1167
+ test,
1168
+ test as default,
1169
+ todo,
1170
+ };
1150
1171
  }
1151
1172
 
1152
1173
  interface TestLocationInfo {
@@ -1353,5 +1374,9 @@ declare module "node:test/reporters" {
1353
1374
  class Spec extends Transform {
1354
1375
  constructor();
1355
1376
  }
1356
- export { dot, Spec as spec, tap, TestEvent };
1377
+ /**
1378
+ * The `junit` reporter outputs test results in a jUnit XML format
1379
+ */
1380
+ function junit(source: TestEventGenerator): AsyncGenerator<string, void>;
1381
+ export { dot, Spec as spec, tap, junit, TestEvent };
1357
1382
  }
node/ts4.8/util.d.ts CHANGED
@@ -419,8 +419,14 @@ declare module "util" {
419
419
  * const bigNumber = 123_456_789n;
420
420
  * const bigDecimal = 1_234.123_45;
421
421
  *
422
- * console.log(thousand, million, bigNumber, bigDecimal);
423
- * // 1_000 1_000_000 123_456_789n 1_234.123_45
422
+ * console.log(inspect(thousand, { numericSeparator: true }));
423
+ * // 1_000
424
+ * console.log(inspect(million, { numericSeparator: true }));
425
+ * // 1_000_000
426
+ * console.log(inspect(bigNumber, { numericSeparator: true }));
427
+ * // 123_456_789n
428
+ * console.log(inspect(bigDecimal, { numericSeparator: true }));
429
+ * // 1_234.123_45
424
430
  * ```
425
431
  *
426
432
  * `util.inspect()` is a synchronous method intended for debugging. Its maximum
@@ -1087,6 +1093,8 @@ declare module "util" {
1087
1093
  * const stats = await stat('.');
1088
1094
  * console.log(`This directory is owned by ${stats.uid}`);
1089
1095
  * }
1096
+ *
1097
+ * callStat();
1090
1098
  * ```
1091
1099
  *
1092
1100
  * If there is an `original[util.promisify.custom]` property present, `promisify`will return its value, see `Custom promisified functions`.
@@ -1632,7 +1640,7 @@ declare module "util" {
1632
1640
  * params.set('foo', 'def');
1633
1641
  * params.set('baz', 'xyz');
1634
1642
  * console.log(params.toString());
1635
- * // Prints: foo=def&#x26;bar=1&#x26;baz=xyz
1643
+ * // Prints: foo=def;bar=1;baz=xyz
1636
1644
  * ```
1637
1645
  */
1638
1646
  set(name: string, value: string): void;
node/util.d.ts CHANGED
@@ -419,8 +419,14 @@ declare module "util" {
419
419
  * const bigNumber = 123_456_789n;
420
420
  * const bigDecimal = 1_234.123_45;
421
421
  *
422
- * console.log(thousand, million, bigNumber, bigDecimal);
423
- * // 1_000 1_000_000 123_456_789n 1_234.123_45
422
+ * console.log(inspect(thousand, { numericSeparator: true }));
423
+ * // 1_000
424
+ * console.log(inspect(million, { numericSeparator: true }));
425
+ * // 1_000_000
426
+ * console.log(inspect(bigNumber, { numericSeparator: true }));
427
+ * // 123_456_789n
428
+ * console.log(inspect(bigDecimal, { numericSeparator: true }));
429
+ * // 1_234.123_45
424
430
  * ```
425
431
  *
426
432
  * `util.inspect()` is a synchronous method intended for debugging. Its maximum
@@ -1087,6 +1093,8 @@ declare module "util" {
1087
1093
  * const stats = await stat('.');
1088
1094
  * console.log(`This directory is owned by ${stats.uid}`);
1089
1095
  * }
1096
+ *
1097
+ * callStat();
1090
1098
  * ```
1091
1099
  *
1092
1100
  * If there is an `original[util.promisify.custom]` property present, `promisify`will return its value, see `Custom promisified functions`.
@@ -1632,7 +1640,7 @@ declare module "util" {
1632
1640
  * params.set('foo', 'def');
1633
1641
  * params.set('baz', 'xyz');
1634
1642
  * console.log(params.toString());
1635
- * // Prints: foo=def&#x26;bar=1&#x26;baz=xyz
1643
+ * // Prints: foo=def;bar=1;baz=xyz
1636
1644
  * ```
1637
1645
  */
1638
1646
  set(name: string, value: string): void;