@types/node 24.13.5 → 24.19.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 (75) hide show
  1. {node v24.13 → node v24.19}/README.md +2 -2
  2. {node v24.13 → node v24.19}/async_hooks.d.ts +18 -22
  3. {node v24.13 → node v24.19}/buffer.buffer.d.ts +10 -5
  4. {node v24.13 → node v24.19}/buffer.d.ts +7 -0
  5. {node v24.13 → node v24.19}/child_process.d.ts +5 -1
  6. {node v24.13 → node v24.19}/crypto.d.ts +114 -47
  7. {node v24.13 → node v24.19}/dgram.d.ts +119 -4
  8. {node v24.13 → node v24.19}/dns/promises.d.ts +5 -5
  9. {node v24.13 → node v24.19}/dns.d.ts +6 -6
  10. {node v24.13 → node v24.19}/events.d.ts +13 -22
  11. {node v24.13 → node v24.19}/fs/promises.d.ts +79 -66
  12. {node v24.13 → node v24.19}/fs.d.ts +153 -90
  13. {node v24.13 → node v24.19}/http.d.ts +94 -2
  14. {node v24.13 → node v24.19}/http2.d.ts +65 -18
  15. {node v24.13 → node v24.19}/inspector.d.ts +47 -1
  16. {node v24.13 → node v24.19}/inspector.generated.d.ts +167 -0
  17. {node v24.13 → node v24.19}/module.d.ts +1 -0
  18. {node v24.13 → node v24.19}/net.d.ts +139 -15
  19. {node v24.13 → node v24.19}/os.d.ts +30 -30
  20. {node v24.13 → node v24.19}/package.json +3 -18
  21. {node v24.13 → node v24.19}/perf_hooks.d.ts +31 -19
  22. {node v24.13 → node v24.19}/process.d.ts +42 -43
  23. {node v24.13 → node v24.19}/sqlite.d.ts +153 -11
  24. {node v24.13 → node v24.19}/stream/consumers.d.ts +7 -0
  25. {node v24.13 → node v24.19}/stream/web.d.ts +19 -0
  26. {node v24.13 → node v24.19}/stream.d.ts +2 -1
  27. {node v24.13 → node v24.19}/test.d.ts +320 -13
  28. {node v24.13 → node v24.19}/tls.d.ts +50 -15
  29. {node v24.13 → node v24.19}/ts5.6/buffer.buffer.d.ts +5 -0
  30. {node v24.13 → node v24.19}/tty.d.ts +4 -3
  31. {node v24.13 → node v24.19}/url.d.ts +27 -3
  32. {node v24.13 → node v24.19}/util.d.ts +42 -2
  33. {node v24.13 → node v24.19}/v8.d.ts +51 -23
  34. {node v24.13 → node v24.19}/vm.d.ts +52 -87
  35. {node v24.13 → node v24.19}/zlib.d.ts +17 -0
  36. {node v24.13 → node v24.19}/LICENSE +0 -0
  37. {node v24.13 → node v24.19}/assert/strict.d.ts +0 -0
  38. {node v24.13 → node v24.19}/assert.d.ts +0 -0
  39. {node v24.13 → node v24.19}/cluster.d.ts +0 -0
  40. {node v24.13 → node v24.19}/compatibility/iterators.d.ts +0 -0
  41. {node v24.13 → node v24.19}/console.d.ts +0 -0
  42. {node v24.13 → node v24.19}/constants.d.ts +0 -0
  43. {node v24.13 → node v24.19}/diagnostics_channel.d.ts +0 -0
  44. {node v24.13 → node v24.19}/domain.d.ts +0 -0
  45. {node v24.13 → node v24.19}/globals.d.ts +0 -0
  46. {node v24.13 → node v24.19}/globals.typedarray.d.ts +0 -0
  47. {node v24.13 → node v24.19}/https.d.ts +0 -0
  48. {node v24.13 → node v24.19}/index.d.ts +0 -0
  49. {node v24.13 → node v24.19}/path.d.ts +0 -0
  50. {node v24.13 → node v24.19}/punycode.d.ts +0 -0
  51. {node v24.13 → node v24.19}/querystring.d.ts +0 -0
  52. {node v24.13 → node v24.19}/readline/promises.d.ts +0 -0
  53. {node v24.13 → node v24.19}/readline.d.ts +0 -0
  54. {node v24.13 → node v24.19}/repl.d.ts +0 -0
  55. {node v24.13 → node v24.19}/sea.d.ts +0 -0
  56. {node v24.13 → node v24.19}/stream/promises.d.ts +0 -0
  57. {node v24.13 → node v24.19}/string_decoder.d.ts +0 -0
  58. {node v24.13 → node v24.19}/timers/promises.d.ts +0 -0
  59. {node v24.13 → node v24.19}/timers.d.ts +0 -0
  60. {node v24.13 → node v24.19}/trace_events.d.ts +0 -0
  61. {node v24.13 → node v24.19}/ts5.6/compatibility/float16array.d.ts +0 -0
  62. {node v24.13 → node v24.19}/ts5.6/globals.typedarray.d.ts +0 -0
  63. {node v24.13 → node v24.19}/ts5.6/index.d.ts +0 -0
  64. {node v24.13 → node v24.19}/ts5.7/compatibility/float16array.d.ts +0 -0
  65. {node v24.13 → node v24.19}/ts5.7/index.d.ts +0 -0
  66. {node v24.13 → node v24.19}/wasi.d.ts +0 -0
  67. {node v24.13 → node v24.19}/web-globals/abortcontroller.d.ts +0 -0
  68. {node v24.13 → node v24.19}/web-globals/crypto.d.ts +0 -0
  69. {node v24.13 → node v24.19}/web-globals/domexception.d.ts +0 -0
  70. {node v24.13 → node v24.19}/web-globals/events.d.ts +0 -0
  71. {node v24.13 → node v24.19}/web-globals/fetch.d.ts +0 -0
  72. {node v24.13 → node v24.19}/web-globals/navigator.d.ts +0 -0
  73. {node v24.13 → node v24.19}/web-globals/storage.d.ts +0 -0
  74. {node v24.13 → node v24.19}/web-globals/streams.d.ts +0 -0
  75. {node v24.13 → node v24.19}/worker_threads.d.ts +0 -0
@@ -42,6 +42,10 @@ declare module "dgram" {
42
42
  exclusive?: boolean | undefined;
43
43
  fd?: number | undefined;
44
44
  }
45
+ interface BindSyncOptions {
46
+ port?: number | undefined;
47
+ address?: string | undefined;
48
+ }
45
49
  type SocketType = "udp4" | "udp6";
46
50
  interface SocketOptions extends Abortable {
47
51
  type: SocketType;
@@ -137,10 +141,12 @@ declare module "dgram" {
137
141
  * messages on a named `port` and optional `address`. If `port` is not
138
142
  * specified or is `0`, the operating system will attempt to bind to a
139
143
  * random port. If `address` is not specified, the operating system will
140
- * attempt to listen on all addresses. Once binding is complete, a `'listening'` event is emitted and the optional `callback` function is
144
+ * attempt to listen on all addresses. Once binding is complete, a
145
+ * `'listening'` event is emitted and the optional `callback` function is
141
146
  * called.
142
147
  *
143
- * Specifying both a `'listening'` event listener and passing a `callback` to the `socket.bind()` method is not harmful but not very
148
+ * Specifying both a `'listening'` event listener and passing a
149
+ * `callback` to the `socket.bind()` method is not harmful but not very
144
150
  * useful.
145
151
  *
146
152
  * A bound datagram socket keeps the Node.js process running to receive
@@ -177,9 +183,82 @@ declare module "dgram" {
177
183
  * @param callback with no parameters. Called when binding is complete.
178
184
  */
179
185
  bind(port?: number, address?: string, callback?: () => void): this;
180
- bind(port?: number, callback?: () => void): this;
181
- bind(callback?: () => void): this;
186
+ bind(port: number, callback: () => void): this;
187
+ bind(callback: () => void): this;
188
+ /**
189
+ * For UDP sockets, causes the `dgram.Socket` to listen for datagram
190
+ * messages on a named `port` and optional `address` that are passed as
191
+ * properties of an `options` object passed as the first argument. If
192
+ * `port` is not specified or is `0`, the operating system will attempt
193
+ * to bind to a random port. If `address` is not specified, the operating
194
+ * system will attempt to listen on all addresses. Once binding is
195
+ * complete, a `'listening'` event is emitted and the optional `callback`
196
+ * function is called.
197
+ *
198
+ * The `options` object may contain a `fd` property. When a `fd` greater
199
+ * than `0` is set, it will wrap around an existing socket with the given
200
+ * file descriptor. In this case, the properties of `port` and `address`
201
+ * will be ignored.
202
+ *
203
+ * Specifying both a `'listening'` event listener and passing a
204
+ * `callback` to the `socket.bind()` method is not harmful but not very
205
+ * useful.
206
+ *
207
+ * The `options` object may contain an additional `exclusive` property that is
208
+ * used when using `dgram.Socket` objects with the [`cluster`](https://nodejs.org/docs/latest-v24.x/api/cluster.html) module. When
209
+ * `exclusive` is set to `false` (the default), cluster workers will use the same
210
+ * underlying socket handle allowing connection handling duties to be shared.
211
+ * When `exclusive` is `true`, however, the handle is not shared and attempted
212
+ * port sharing results in an error. Creating a `dgram.Socket` with the `reusePort`
213
+ * option set to `true` causes `exclusive` to always be `true` when `socket.bind()`
214
+ * is called.
215
+ *
216
+ * A bound datagram socket keeps the Node.js process running to receive
217
+ * datagram messages.
218
+ *
219
+ * If binding fails, an `'error'` event is generated. In rare case (e.g.
220
+ * attempting to bind with a closed socket), an `Error` may be thrown.
221
+ *
222
+ * An example socket listening on an exclusive port is shown below.
223
+ *
224
+ * ```js
225
+ * socket.bind({
226
+ * address: 'localhost',
227
+ * port: 8000,
228
+ * exclusive: true,
229
+ * });
230
+ * ```
231
+ * @since v0.11.14
232
+ * @param options Required. Supports the following properties:
233
+ */
182
234
  bind(options: BindOptions, callback?: () => void): this;
235
+ /**
236
+ * The synchronous counterpart of `socket.bind()`. `bind(2)` is a local,
237
+ * non-blocking system call, so the bind is performed inline and the resolved
238
+ * address is returned immediately, including the operating-system-assigned
239
+ * ephemeral port when `port` is `0`:
240
+ *
241
+ * ```js
242
+ * const dgram = require('node:dgram');
243
+ *
244
+ * const socket = dgram.createSocket('udp4');
245
+ * const address = socket.bindSync({ address: '0.0.0.0', port: 0 });
246
+ * console.log(address); // e.g. { address: '0.0.0.0', family: 'IPv4', port: 53124 }
247
+ * ```
248
+ *
249
+ * A bind failure such as `EADDRINUSE` is thrown synchronously rather than emitted
250
+ * as an `'error'` event. After `bindSync()` returns, `socket.address()` is
251
+ * valid synchronously and the `'listening'` event is emitted on the next tick.
252
+ *
253
+ * `address` must be a numeric IP literal; `bindSync()` never performs DNS
254
+ * resolution (asynchronous name resolution being the only genuinely blocking part
255
+ * of binding). Incoming datagrams continue to be delivered asynchronously via the
256
+ * `'message'` event. `bindSync()` always binds the socket's own handle and
257
+ * does not participate in [`cluster`](https://nodejs.org/docs/latest-v24.x/api/cluster.html) handle sharing.
258
+ * @since v24.19.0
259
+ * @returns The bound address as returned by `socket.address()`.
260
+ */
261
+ bindSync(options?: BindSyncOptions): AddressInfo;
183
262
  /**
184
263
  * Close the underlying socket and stop listening for data on it. If a callback is
185
264
  * provided, it is added as a listener for the `'close'` event.
@@ -202,6 +281,42 @@ declare module "dgram" {
202
281
  */
203
282
  connect(port: number, address?: string, callback?: () => void): void;
204
283
  connect(port: number, callback: () => void): void;
284
+ /**
285
+ * The synchronous counterpart of `socket.connect()`. For a UDP socket
286
+ * `connect(2)` only records the default peer address and is a local, non-blocking
287
+ * system call, so the association is performed inline. Any error raised by the
288
+ * call itself (for example `EAFNOSUPPORT` for a mismatched address family) is
289
+ * thrown synchronously rather than reported via the `'error'` event. Because
290
+ * `connect(2)` does not probe reachability, errors such as `ECONNREFUSED` are
291
+ * still surfaced asynchronously on a later send or receive, exactly as for
292
+ * `socket.connect()`:
293
+ *
294
+ * ```js
295
+ * const dgram = require('node:dgram');
296
+ *
297
+ * const socket = dgram.createSocket('udp4');
298
+ * socket.connectSync(41234, '127.0.0.1');
299
+ * console.log(socket.remoteAddress()); // { address: '127.0.0.1', family: 'IPv4', port: 41234 }
300
+ * ```
301
+ *
302
+ * If the socket is still unbound it is bound synchronously first. After
303
+ * `connectSync()` returns, `socket.remoteAddress()` is valid synchronously
304
+ * and the `'connect'` event is emitted on the next tick. Trying to call
305
+ * `connectSync()` on an already connected socket throws an
306
+ * `ERR_SOCKET_DGRAM_IS_CONNECTED` exception, and calling it while an
307
+ * asynchronous `socket.bind()` is still in progress throws an
308
+ * `ERR_SOCKET_ALREADY_BOUND` exception.
309
+ *
310
+ * `address` must be a numeric IP literal; `connectSync()` never performs DNS
311
+ * resolution (asynchronous name resolution being the only genuinely blocking part
312
+ * of connecting).
313
+ * @since v24.19.0
314
+ * @param address A numeric IP address to connect to. Unlike
315
+ * `socket.connect()`, no DNS resolution is performed, so a host name is not
316
+ * accepted. If omitted, `'127.0.0.1'` (for `udp4` sockets) or `'::1'` (for
317
+ * `udp6` sockets) is used.
318
+ */
319
+ connectSync(port: number, address?: string): void;
205
320
  /**
206
321
  * A synchronous function that disassociates a connected `dgram.Socket` from
207
322
  * its remote address. Trying to call `disconnect()` on an unbound or already
@@ -189,7 +189,7 @@ declare module "dns/promises" {
189
189
  * refresh: 900,
190
190
  * retry: 900,
191
191
  * expire: 1800,
192
- * minttl: 60 } ]
192
+ * minttl: 60 } ];
193
193
  * ```
194
194
  * @since v10.6.0
195
195
  */
@@ -232,7 +232,7 @@ declare module "dns/promises" {
232
232
  * regexp: '',
233
233
  * replacement: '_sip._udp.example.com',
234
234
  * order: 30,
235
- * preference: 100
235
+ * preference: 100,
236
236
  * }
237
237
  * ```
238
238
  * @since v10.6.0
@@ -271,7 +271,7 @@ declare module "dns/promises" {
271
271
  * refresh: 10000,
272
272
  * retry: 2400,
273
273
  * expire: 604800,
274
- * minttl: 3600
274
+ * minttl: 3600,
275
275
  * }
276
276
  * ```
277
277
  * @since v10.6.0
@@ -291,7 +291,7 @@ declare module "dns/promises" {
291
291
  * priority: 10,
292
292
  * weight: 5,
293
293
  * port: 21223,
294
- * name: 'service.example.com'
294
+ * name: 'service.example.com',
295
295
  * }
296
296
  * ```
297
297
  * @since v10.6.0
@@ -312,7 +312,7 @@ declare module "dns/promises" {
312
312
  * certUsage: 3,
313
313
  * selector: 1,
314
314
  * match: 1,
315
- * data: [ArrayBuffer]
315
+ * data: [ArrayBuffer],
316
316
  * }
317
317
  * ```
318
318
  * @since v23.9.0, v22.15.0
@@ -81,7 +81,7 @@ declare module "dns" {
81
81
  */
82
82
  all?: boolean | undefined;
83
83
  /**
84
- * When `verbatim`, the resolved addresses are return unsorted. When `ipv4first`, the resolved addresses are sorted
84
+ * When `verbatim`, the resolved addresses are returned unsorted. When `ipv4first`, the resolved addresses are sorted
85
85
  * by placing IPv4 addresses before IPv6 addresses. When `ipv6first`, the resolved addresses are sorted by placing IPv6
86
86
  * addresses before IPv4 addresses. Default value is configurable using
87
87
  * {@link setDefaultResultOrder} or [`--dns-result-order`](https://nodejs.org/docs/latest-v24.x/api/cli.html#--dns-result-orderorder).
@@ -539,7 +539,7 @@ declare module "dns" {
539
539
  * regexp: '',
540
540
  * replacement: '_sip._udp.example.com',
541
541
  * order: 30,
542
- * preference: 100
542
+ * preference: 100,
543
543
  * }
544
544
  * ```
545
545
  * @since v0.9.12
@@ -596,7 +596,7 @@ declare module "dns" {
596
596
  * refresh: 10000,
597
597
  * retry: 2400,
598
598
  * expire: 604800,
599
- * minttl: 3600
599
+ * minttl: 3600,
600
600
  * }
601
601
  * ```
602
602
  * @since v0.11.10
@@ -622,7 +622,7 @@ declare module "dns" {
622
622
  * priority: 10,
623
623
  * weight: 5,
624
624
  * port: 21223,
625
- * name: 'service.example.com'
625
+ * name: 'service.example.com',
626
626
  * }
627
627
  * ```
628
628
  * @since v0.1.27
@@ -649,7 +649,7 @@ declare module "dns" {
649
649
  * certUsage: 3,
650
650
  * selector: 1,
651
651
  * match: 1,
652
- * data: [ArrayBuffer]
652
+ * data: [ArrayBuffer],
653
653
  * }
654
654
  * ```
655
655
  * @since v23.9.0, v22.15.0
@@ -699,7 +699,7 @@ declare module "dns" {
699
699
  * refresh: 900,
700
700
  * retry: 900,
701
701
  * expire: 1800,
702
- * minttl: 60 } ]
702
+ * minttl: 60 } ];
703
703
  * ```
704
704
  *
705
705
  * DNS server operators may choose not to respond to `ANY` queries. It may be better to call individual methods like {@link resolve4}, {@link resolveMx}, and so on. For more details, see
@@ -278,23 +278,17 @@ declare module "events" {
278
278
  options?: StaticEventEmitterIteratorOptions,
279
279
  ): NodeJS.AsyncIterator<any[]>;
280
280
  /**
281
- * A class method that returns the number of listeners for the given `eventName` registered on the given `emitter`.
281
+ * Returns the number of registered listeners for the event named `eventName`.
282
282
  *
283
- * ```js
284
- * import { EventEmitter, listenerCount } from 'node:events';
283
+ * For `EventEmitter`s this behaves exactly the same as calling `.listenerCount`
284
+ * on the emitter.
285
285
  *
286
- * const myEmitter = new EventEmitter();
287
- * myEmitter.on('event', () => {});
288
- * myEmitter.on('event', () => {});
289
- * console.log(listenerCount(myEmitter, 'event'));
290
- * // Prints: 2
291
- * ```
286
+ * For `EventTarget`s this is the only way to obtain the listener count. This can
287
+ * be useful for debugging and diagnostic purposes.
292
288
  * @since v0.9.12
293
- * @deprecated Since v3.2.0 - Use `listenerCount` instead.
294
- * @param emitter The emitter to query
295
- * @param eventName The event name
296
289
  */
297
- static listenerCount(emitter: NodeJS.EventEmitter, eventName: string | symbol): number;
290
+ static listenerCount(emitter: EventEmitter, eventName: string | symbol): number;
291
+ static listenerCount(emitter: EventTarget, eventName: string): number;
298
292
  /**
299
293
  * Returns a copy of the array of listeners for the event named `eventName`.
300
294
  *
@@ -386,15 +380,12 @@ declare module "events" {
386
380
  * import { addAbortListener } from 'node:events';
387
381
  *
388
382
  * function example(signal) {
389
- * let disposable;
390
- * try {
391
- * signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
392
- * disposable = addAbortListener(signal, (e) => {
393
- * // Do something when signal is aborted.
394
- * });
395
- * } finally {
396
- * disposable?.[Symbol.dispose]();
397
- * }
383
+ * signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
384
+ * // addAbortListener() returns a disposable, so the `using` keyword ensures
385
+ * // the abort listener is automatically removed when this scope exits.
386
+ * using _ = addAbortListener(signal, (e) => {
387
+ * // Do something when signal is aborted.
388
+ * });
398
389
  * }
399
390
  * ```
400
391
  * @since v20.5.0
@@ -9,9 +9,8 @@
9
9
  * @since v10.0.0
10
10
  */
11
11
  declare module "fs/promises" {
12
- import { NonSharedBuffer } from "node:buffer";
12
+ import { BufferView, NonSharedBuffer } from "node:buffer";
13
13
  import { Abortable } from "node:events";
14
- import { Stream } from "node:stream";
15
14
  import { ReadableStream } from "node:stream/web";
16
15
  import {
17
16
  BigIntStats,
@@ -31,6 +30,10 @@ declare module "fs/promises" {
31
30
  OpenDirOptions,
32
31
  OpenMode,
33
32
  PathLike,
33
+ ReadFileOptions,
34
+ ReadFileOptionsWithBuffer,
35
+ ReadFileOptionsWithBufferEncoding,
36
+ ReadFileOptionsWithStringEncoding,
34
37
  ReadOptions,
35
38
  ReadOptionsWithBuffer,
36
39
  ReadPosition,
@@ -281,39 +284,61 @@ declare module "fs/promises" {
281
284
  *
282
285
  * If `options` is a string, then it specifies the `encoding`.
283
286
  *
287
+ * If `buffer` is provided and no encoding is specified, the returned {Buffer} is
288
+ * a view over the supplied buffer containing only the bytes read. If the
289
+ * supplied buffer is too small to contain the entire file, the operation will
290
+ * fail.
291
+ *
284
292
  * The `FileHandle` has to support reading.
285
293
  *
286
- * If one or more `filehandle.read()` calls are made on a file handle and then a `filehandle.readFile()` call is made, the data will be read from the current
294
+ * If one or more `filehandle.read()` calls are made on a file handle and then a
295
+ * `filehandle.readFile()` call is made, the data will be read from the current
287
296
  * position till the end of the file. It doesn't always read from the beginning
288
297
  * of the file.
298
+ *
299
+ * An example using the `buffer` option with a pre-allocated buffer:
300
+ *
301
+ * ```js
302
+ * import { Buffer } from 'node:buffer';
303
+ * import { open } from 'node:fs/promises';
304
+ *
305
+ * const file = await open('./some/file/to/read');
306
+ * try {
307
+ * const buf = Buffer.alloc(16384);
308
+ * const contents = await file.readFile({ buffer: buf });
309
+ * console.log(contents); // A view over `buf` containing only the bytes read
310
+ * } finally {
311
+ * await file.close();
312
+ * }
313
+ * ```
314
+ *
315
+ * An example using the `buffer` option with a function returning a buffer:
316
+ *
317
+ * ```js
318
+ * import { Buffer } from 'node:buffer';
319
+ * import { open } from 'node:fs/promises';
320
+ *
321
+ * const file = await open('./some/file/to/read');
322
+ * try {
323
+ * const contents = await file.readFile({
324
+ * buffer: (size) => Buffer.alloc(size),
325
+ * });
326
+ * console.log(contents);
327
+ * } finally {
328
+ * await file.close();
329
+ * }
330
+ * ```
289
331
  * @since v10.0.0
290
- * @return Fulfills upon a successful read with the contents of the file. If no encoding is specified (using `options.encoding`), the data is returned as a {Buffer} object. Otherwise, the
291
- * data will be a string.
332
+ * @returns Fulfills upon a successful read with the contents of the
333
+ * file. If no encoding is specified (using `options.encoding`), the data is
334
+ * returned as a `Buffer` object. Otherwise, the data will be a string.
292
335
  */
293
- readFile(
294
- options?:
295
- | ({ encoding?: null | undefined } & Abortable)
296
- | null,
297
- ): Promise<NonSharedBuffer>;
298
- /**
299
- * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
300
- * The `FileHandle` must have been opened for reading.
301
- */
302
- readFile(
303
- options:
304
- | ({ encoding: BufferEncoding } & Abortable)
305
- | BufferEncoding,
306
- ): Promise<string>;
307
- /**
308
- * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
309
- * The `FileHandle` must have been opened for reading.
310
- */
311
- readFile(
312
- options?:
313
- | (ObjectEncodingOptions & Abortable)
314
- | BufferEncoding
315
- | null,
316
- ): Promise<string | NonSharedBuffer>;
336
+ readFile<T extends NodeJS.ArrayBufferView>(
337
+ options: Omit<ReadFileOptionsWithBuffer<T>, "flag">,
338
+ ): Promise<BufferView<T>>;
339
+ readFile(options?: Omit<ReadFileOptionsWithBufferEncoding, "flag"> | null): Promise<NonSharedBuffer>;
340
+ readFile(options: Omit<ReadFileOptionsWithStringEncoding, "flag"> | BufferEncoding): Promise<string>;
341
+ readFile(options: Omit<ReadFileOptions, "flag"> | BufferEncoding | null): Promise<string | NonSharedBuffer>;
317
342
  /**
318
343
  * Convenience method to create a `readline` interface and stream over the file.
319
344
  * See `filehandle.createReadStream()` for the options.
@@ -337,14 +362,28 @@ declare module "fs/promises" {
337
362
  stat(
338
363
  opts?: StatOptions & {
339
364
  bigint?: false | undefined;
365
+ throwIfNoEntry?: true | undefined;
340
366
  },
341
367
  ): Promise<Stats>;
342
368
  stat(
343
369
  opts: StatOptions & {
344
370
  bigint: true;
371
+ throwIfNoEntry?: true | undefined;
345
372
  },
346
373
  ): Promise<BigIntStats>;
347
- stat(opts?: StatOptions): Promise<Stats | BigIntStats>;
374
+ stat(
375
+ opts?: StatOptions & {
376
+ bigint?: false | undefined;
377
+ throwIfNoEntry: false;
378
+ },
379
+ ): Promise<Stats | undefined>;
380
+ stat(
381
+ opts: StatOptions & {
382
+ bigint: true;
383
+ throwIfNoEntry: false;
384
+ },
385
+ ): Promise<BigIntStats | undefined>;
386
+ stat(opts?: StatOptions): Promise<Stats | BigIntStats | undefined>;
348
387
  /**
349
388
  * Truncates the file.
350
389
  *
@@ -1172,50 +1211,21 @@ declare module "fs/promises" {
1172
1211
  * @param path filename or `FileHandle`
1173
1212
  * @return Fulfills with the contents of the file.
1174
1213
  */
1214
+ function readFile<T extends NodeJS.ArrayBufferView>(
1215
+ path: PathLike | FileHandle,
1216
+ options: ReadFileOptionsWithBuffer<T>,
1217
+ ): Promise<BufferView<T>>;
1175
1218
  function readFile(
1176
1219
  path: PathLike | FileHandle,
1177
- options?:
1178
- | ({
1179
- encoding?: null | undefined;
1180
- flag?: OpenMode | undefined;
1181
- } & Abortable)
1182
- | null,
1220
+ options?: ReadFileOptionsWithBufferEncoding | null,
1183
1221
  ): Promise<NonSharedBuffer>;
1184
- /**
1185
- * Asynchronously reads the entire contents of a file.
1186
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1187
- * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
1188
- * @param options An object that may contain an optional flag.
1189
- * If a flag is not provided, it defaults to `'r'`.
1190
- */
1191
1222
  function readFile(
1192
1223
  path: PathLike | FileHandle,
1193
- options:
1194
- | ({
1195
- encoding: BufferEncoding;
1196
- flag?: OpenMode | undefined;
1197
- } & Abortable)
1198
- | BufferEncoding,
1224
+ options: ReadFileOptionsWithStringEncoding | BufferEncoding,
1199
1225
  ): Promise<string>;
1200
- /**
1201
- * Asynchronously reads the entire contents of a file.
1202
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1203
- * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
1204
- * @param options An object that may contain an optional flag.
1205
- * If a flag is not provided, it defaults to `'r'`.
1206
- */
1207
1226
  function readFile(
1208
1227
  path: PathLike | FileHandle,
1209
- options?:
1210
- | (
1211
- & ObjectEncodingOptions
1212
- & Abortable
1213
- & {
1214
- flag?: OpenMode | undefined;
1215
- }
1216
- )
1217
- | BufferEncoding
1218
- | null,
1228
+ options: ReadFileOptions | BufferEncoding | null,
1219
1229
  ): Promise<string | NonSharedBuffer>;
1220
1230
  /**
1221
1231
  * Asynchronously open a directory for iterative scanning. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for more detail.
@@ -1312,6 +1322,9 @@ declare module "fs/promises" {
1312
1322
  */
1313
1323
  function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
1314
1324
  /**
1325
+ * When `followSymlinks` is enabled, detected symbolic link cycles are not
1326
+ * traversed recursively.
1327
+ *
1315
1328
  * ```js
1316
1329
  * import { glob } from 'node:fs/promises';
1317
1330
  *