@chainlink/external-adapter-framework 2.7.2 → 2.9.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 (175) hide show
  1. package/README.md +1 -1
  2. package/adapter/basic.js +21 -4
  3. package/adapter/basic.js.map +1 -1
  4. package/adapter/endpoint.js +13 -0
  5. package/adapter/endpoint.js.map +1 -1
  6. package/adapter/por.js +6 -6
  7. package/adapter/por.js.map +1 -1
  8. package/adapter/price.js +1 -0
  9. package/adapter/price.js.map +1 -1
  10. package/cache/local.js +5 -1
  11. package/cache/local.js.map +1 -1
  12. package/cache/redis.js +3 -1
  13. package/cache/redis.js.map +1 -1
  14. package/cache/response.js +5 -0
  15. package/cache/response.js.map +1 -1
  16. package/config/index.js +9 -6
  17. package/config/index.js.map +1 -1
  18. package/generator-adapter/node_modules/.yarn-integrity +4 -4
  19. package/generator-adapter/node_modules/@types/node/README.md +3 -3
  20. package/generator-adapter/node_modules/@types/node/assert/strict.d.ts +105 -2
  21. package/generator-adapter/node_modules/@types/node/assert.d.ts +162 -101
  22. package/generator-adapter/node_modules/@types/node/async_hooks.d.ts +25 -5
  23. package/generator-adapter/node_modules/@types/node/buffer.buffer.d.ts +9 -0
  24. package/generator-adapter/node_modules/@types/node/buffer.d.ts +9 -5
  25. package/generator-adapter/node_modules/@types/node/child_process.d.ts +67 -44
  26. package/generator-adapter/node_modules/@types/node/cluster.d.ts +19 -20
  27. package/generator-adapter/node_modules/@types/node/compatibility/iterators.d.ts +1 -0
  28. package/generator-adapter/node_modules/@types/node/console.d.ts +19 -18
  29. package/generator-adapter/node_modules/@types/node/crypto.d.ts +1247 -355
  30. package/generator-adapter/node_modules/@types/node/dgram.d.ts +10 -9
  31. package/generator-adapter/node_modules/@types/node/diagnostics_channel.d.ts +1 -3
  32. package/generator-adapter/node_modules/@types/node/dns/promises.d.ts +1 -1
  33. package/generator-adapter/node_modules/@types/node/dns.d.ts +23 -18
  34. package/generator-adapter/node_modules/@types/node/domain.d.ts +1 -1
  35. package/generator-adapter/node_modules/@types/node/events.d.ts +81 -35
  36. package/generator-adapter/node_modules/@types/node/fs/promises.d.ts +62 -22
  37. package/generator-adapter/node_modules/@types/node/fs.d.ts +364 -98
  38. package/generator-adapter/node_modules/@types/node/globals.d.ts +4 -4
  39. package/generator-adapter/node_modules/@types/node/globals.typedarray.d.ts +20 -0
  40. package/generator-adapter/node_modules/@types/node/http.d.ts +120 -32
  41. package/generator-adapter/node_modules/@types/node/http2.d.ts +185 -65
  42. package/generator-adapter/node_modules/@types/node/https.d.ts +92 -63
  43. package/generator-adapter/node_modules/@types/node/index.d.ts +10 -5
  44. package/generator-adapter/node_modules/@types/node/inspector.d.ts +277 -0
  45. package/generator-adapter/node_modules/@types/node/inspector.generated.d.ts +908 -886
  46. package/generator-adapter/node_modules/@types/node/module.d.ts +21 -18
  47. package/generator-adapter/node_modules/@types/node/net.d.ts +35 -16
  48. package/generator-adapter/node_modules/@types/node/os.d.ts +22 -10
  49. package/generator-adapter/node_modules/@types/node/package.json +13 -3
  50. package/generator-adapter/node_modules/@types/node/path.d.ts +1 -1
  51. package/generator-adapter/node_modules/@types/node/perf_hooks.d.ts +28 -16
  52. package/generator-adapter/node_modules/@types/node/process.d.ts +30 -30
  53. package/generator-adapter/node_modules/@types/node/punycode.d.ts +1 -1
  54. package/generator-adapter/node_modules/@types/node/querystring.d.ts +1 -1
  55. package/generator-adapter/node_modules/@types/node/readline/promises.d.ts +1 -1
  56. package/generator-adapter/node_modules/@types/node/readline.d.ts +13 -13
  57. package/generator-adapter/node_modules/@types/node/repl.d.ts +23 -13
  58. package/generator-adapter/node_modules/@types/node/sea.d.ts +10 -1
  59. package/generator-adapter/node_modules/@types/node/sqlite.d.ts +245 -23
  60. package/generator-adapter/node_modules/@types/node/stream/consumers.d.ts +2 -2
  61. package/generator-adapter/node_modules/@types/node/stream/web.d.ts +6 -55
  62. package/generator-adapter/node_modules/@types/node/stream.d.ts +63 -37
  63. package/generator-adapter/node_modules/@types/node/string_decoder.d.ts +3 -3
  64. package/generator-adapter/node_modules/@types/node/test.d.ts +196 -40
  65. package/generator-adapter/node_modules/@types/node/timers/promises.d.ts +1 -1
  66. package/generator-adapter/node_modules/@types/node/timers.d.ts +1 -3
  67. package/generator-adapter/node_modules/@types/node/tls.d.ts +124 -114
  68. package/generator-adapter/node_modules/@types/node/trace_events.d.ts +6 -6
  69. package/generator-adapter/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +10 -2
  70. package/generator-adapter/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  71. package/generator-adapter/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +17 -0
  72. package/generator-adapter/node_modules/@types/node/ts5.6/index.d.ts +12 -5
  73. package/generator-adapter/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  74. package/generator-adapter/node_modules/@types/node/ts5.7/index.d.ts +103 -0
  75. package/generator-adapter/node_modules/@types/node/tty.d.ts +1 -1
  76. package/generator-adapter/node_modules/@types/node/url.d.ts +109 -33
  77. package/generator-adapter/node_modules/@types/node/util.d.ts +31 -305
  78. package/generator-adapter/node_modules/@types/node/v8.d.ts +41 -8
  79. package/generator-adapter/node_modules/@types/node/vm.d.ts +258 -107
  80. package/generator-adapter/node_modules/@types/node/wasi.d.ts +23 -2
  81. package/generator-adapter/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
  82. package/generator-adapter/node_modules/@types/node/web-globals/events.d.ts +3 -0
  83. package/generator-adapter/node_modules/@types/node/web-globals/fetch.d.ts +4 -0
  84. package/generator-adapter/node_modules/@types/node/web-globals/navigator.d.ts +3 -0
  85. package/generator-adapter/node_modules/@types/node/web-globals/streams.d.ts +22 -0
  86. package/generator-adapter/node_modules/@types/node/worker_threads.d.ts +142 -51
  87. package/generator-adapter/node_modules/@types/node/zlib.d.ts +36 -31
  88. package/generator-adapter/node_modules/undici-types/agent.d.ts +12 -11
  89. package/generator-adapter/node_modules/undici-types/api.d.ts +24 -24
  90. package/generator-adapter/node_modules/undici-types/balanced-pool.d.ts +11 -11
  91. package/generator-adapter/node_modules/undici-types/cache-interceptor.d.ts +172 -0
  92. package/generator-adapter/node_modules/undici-types/client-stats.d.ts +15 -0
  93. package/generator-adapter/node_modules/undici-types/client.d.ts +18 -18
  94. package/generator-adapter/node_modules/undici-types/cookies.d.ts +2 -0
  95. package/generator-adapter/node_modules/undici-types/diagnostics-channel.d.ts +18 -10
  96. package/generator-adapter/node_modules/undici-types/dispatcher.d.ts +119 -99
  97. package/generator-adapter/node_modules/undici-types/env-http-proxy-agent.d.ts +4 -3
  98. package/generator-adapter/node_modules/undici-types/errors.d.ts +66 -54
  99. package/generator-adapter/node_modules/undici-types/eventsource.d.ts +9 -4
  100. package/generator-adapter/node_modules/undici-types/fetch.d.ts +18 -16
  101. package/generator-adapter/node_modules/undici-types/formdata.d.ts +7 -7
  102. package/generator-adapter/node_modules/undici-types/global-dispatcher.d.ts +4 -4
  103. package/generator-adapter/node_modules/undici-types/global-origin.d.ts +5 -5
  104. package/generator-adapter/node_modules/undici-types/h2c-client.d.ts +73 -0
  105. package/generator-adapter/node_modules/undici-types/handlers.d.ts +8 -8
  106. package/generator-adapter/node_modules/undici-types/header.d.ts +157 -1
  107. package/generator-adapter/node_modules/undici-types/index.d.ts +56 -47
  108. package/generator-adapter/node_modules/undici-types/interceptors.d.ts +30 -8
  109. package/generator-adapter/node_modules/undici-types/mock-agent.d.ts +36 -18
  110. package/generator-adapter/node_modules/undici-types/mock-call-history.d.ts +111 -0
  111. package/generator-adapter/node_modules/undici-types/mock-client.d.ts +6 -4
  112. package/generator-adapter/node_modules/undici-types/mock-errors.d.ts +3 -3
  113. package/generator-adapter/node_modules/undici-types/mock-interceptor.d.ts +21 -20
  114. package/generator-adapter/node_modules/undici-types/mock-pool.d.ts +6 -4
  115. package/generator-adapter/node_modules/undici-types/package.json +1 -1
  116. package/generator-adapter/node_modules/undici-types/patch.d.ts +0 -4
  117. package/generator-adapter/node_modules/undici-types/pool-stats.d.ts +8 -8
  118. package/generator-adapter/node_modules/undici-types/pool.d.ts +14 -12
  119. package/generator-adapter/node_modules/undici-types/proxy-agent.d.ts +5 -4
  120. package/generator-adapter/node_modules/undici-types/readable.d.ts +18 -15
  121. package/generator-adapter/node_modules/undici-types/retry-agent.d.ts +1 -1
  122. package/generator-adapter/node_modules/undici-types/retry-handler.d.ts +19 -10
  123. package/generator-adapter/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  124. package/generator-adapter/node_modules/undici-types/util.d.ts +3 -3
  125. package/generator-adapter/node_modules/undici-types/utility.d.ts +7 -0
  126. package/generator-adapter/node_modules/undici-types/webidl.d.ts +142 -29
  127. package/generator-adapter/node_modules/undici-types/websocket.d.ts +38 -2
  128. package/generator-adapter/package.json +1 -1
  129. package/metrics/index.js +3 -0
  130. package/metrics/index.js.map +1 -1
  131. package/package.json +9 -9
  132. package/rate-limiting/burst.js +6 -6
  133. package/rate-limiting/burst.js.map +1 -1
  134. package/rate-limiting/fixed-interval.js +2 -3
  135. package/rate-limiting/fixed-interval.js.map +1 -1
  136. package/transports/abstract/streaming.js +7 -10
  137. package/transports/abstract/streaming.js.map +1 -1
  138. package/transports/abstract/subscription.js +4 -0
  139. package/transports/abstract/subscription.js.map +1 -1
  140. package/transports/http.js +5 -3
  141. package/transports/http.js.map +1 -1
  142. package/transports/index.js +1 -3
  143. package/transports/index.js.map +1 -1
  144. package/transports/sse.js +6 -2
  145. package/transports/sse.js.map +1 -1
  146. package/transports/websocket.d.ts +9 -1
  147. package/transports/websocket.js +41 -65
  148. package/transports/websocket.js.map +1 -1
  149. package/util/censor/censor-list.js +1 -1
  150. package/util/censor/censor-list.js.map +1 -1
  151. package/util/group-runner.js +3 -2
  152. package/util/group-runner.js.map +1 -1
  153. package/util/index.js +8 -1
  154. package/util/index.js.map +1 -1
  155. package/util/logger.js +8 -1
  156. package/util/logger.js.map +1 -1
  157. package/util/requester.js +11 -3
  158. package/util/requester.js.map +1 -1
  159. package/util/subscription-set/expiring-sorted-set.js +3 -0
  160. package/util/subscription-set/expiring-sorted-set.js.map +1 -1
  161. package/util/subscription-set/redis-sorted-set.js +3 -0
  162. package/util/subscription-set/redis-sorted-set.js.map +1 -1
  163. package/util/subscription-set/subscription-set.js +5 -0
  164. package/util/subscription-set/subscription-set.js.map +1 -1
  165. package/util/testing-utils.js +13 -6
  166. package/util/testing-utils.js.map +1 -1
  167. package/validation/error.js +13 -0
  168. package/validation/error.js.map +1 -1
  169. package/validation/input-params.js +14 -0
  170. package/validation/input-params.js.map +1 -1
  171. package/generator-adapter/node_modules/@types/node/compatibility/disposable.d.ts +0 -14
  172. package/generator-adapter/node_modules/@types/node/compatibility/index.d.ts +0 -9
  173. package/generator-adapter/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
  174. package/generator-adapter/node_modules/undici-types/file.d.ts +0 -39
  175. package/generator-adapter/node_modules/undici-types/filereader.d.ts +0 -54
@@ -16,9 +16,10 @@
16
16
  *
17
17
  * All file system operations have synchronous, callback, and promise-based
18
18
  * forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).
19
- * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/fs.js)
19
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/fs.js)
20
20
  */
21
21
  declare module "fs" {
22
+ import { NonSharedBuffer } from "node:buffer";
22
23
  import * as stream from "node:stream";
23
24
  import { Abortable, EventEmitter } from "node:events";
24
25
  import { URL } from "node:url";
@@ -247,12 +248,6 @@ declare module "fs" {
247
248
  * @since v20.12.0, v18.20.0
248
249
  */
249
250
  parentPath: string;
250
- /**
251
- * Alias for `dirent.parentPath`.
252
- * @since v20.1.0
253
- * @deprecated Since v20.12.0
254
- */
255
- path: string;
256
251
  }
257
252
  /**
258
253
  * A class representing a directory stream.
@@ -331,15 +326,13 @@ declare module "fs" {
331
326
  /**
332
327
  * Calls `dir.close()` if the directory handle is open, and returns a promise that
333
328
  * fulfills when disposal is complete.
334
- * @since v22.17.0
335
- * @experimental
329
+ * @since v24.1.0
336
330
  */
337
331
  [Symbol.asyncDispose](): Promise<void>;
338
332
  /**
339
333
  * Calls `dir.closeSync()` if the directory handle is open, and returns
340
334
  * `undefined`.
341
- * @since v22.17.0
342
- * @experimental
335
+ * @since v24.1.0
343
336
  */
344
337
  [Symbol.dispose](): void;
345
338
  }
@@ -402,23 +395,29 @@ declare module "fs" {
402
395
  * 3. error
403
396
  */
404
397
  addListener(event: string, listener: (...args: any[]) => void): this;
405
- addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
398
+ addListener(event: "change", listener: (eventType: string, filename: string | NonSharedBuffer) => void): this;
406
399
  addListener(event: "close", listener: () => void): this;
407
400
  addListener(event: "error", listener: (error: Error) => void): this;
408
401
  on(event: string, listener: (...args: any[]) => void): this;
409
- on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
402
+ on(event: "change", listener: (eventType: string, filename: string | NonSharedBuffer) => void): this;
410
403
  on(event: "close", listener: () => void): this;
411
404
  on(event: "error", listener: (error: Error) => void): this;
412
405
  once(event: string, listener: (...args: any[]) => void): this;
413
- once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
406
+ once(event: "change", listener: (eventType: string, filename: string | NonSharedBuffer) => void): this;
414
407
  once(event: "close", listener: () => void): this;
415
408
  once(event: "error", listener: (error: Error) => void): this;
416
409
  prependListener(event: string, listener: (...args: any[]) => void): this;
417
- prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
410
+ prependListener(
411
+ event: "change",
412
+ listener: (eventType: string, filename: string | NonSharedBuffer) => void,
413
+ ): this;
418
414
  prependListener(event: "close", listener: () => void): this;
419
415
  prependListener(event: "error", listener: (error: Error) => void): this;
420
416
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
421
- prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
417
+ prependOnceListener(
418
+ event: "change",
419
+ listener: (eventType: string, filename: string | NonSharedBuffer) => void,
420
+ ): this;
422
421
  prependOnceListener(event: "close", listener: () => void): this;
423
422
  prependOnceListener(event: "error", listener: (error: Error) => void): this;
424
423
  }
@@ -458,6 +457,230 @@ declare module "fs" {
458
457
  prependListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
459
458
  prependOnceListener<K extends keyof ReadStreamEvents>(event: K, listener: ReadStreamEvents[K]): this;
460
459
  }
460
+ export interface Utf8StreamOptions {
461
+ /**
462
+ * Appends writes to dest file instead of truncating it.
463
+ * @default true
464
+ */
465
+ append?: boolean | undefined;
466
+ /**
467
+ * Which type of data you can send to the write
468
+ * function, supported values are `'utf8'` or `'buffer'`.
469
+ * @default 'utf8'
470
+ */
471
+ contentMode?: "utf8" | "buffer" | undefined;
472
+ /**
473
+ * A path to a file to be written to (mode controlled by the
474
+ * append option).
475
+ */
476
+ dest?: string | undefined;
477
+ /**
478
+ * A file descriptor, something that is returned by `fs.open()`
479
+ * or `fs.openSync()`.
480
+ */
481
+ fd?: number | undefined;
482
+ /**
483
+ * An object that has the same API as the `fs` module, useful
484
+ * for mocking, testing, or customizing the behavior of the stream.
485
+ */
486
+ fs?: object | undefined;
487
+ /**
488
+ * Perform a `fs.fsyncSync()` every time a write is
489
+ * completed.
490
+ */
491
+ fsync?: boolean | undefined;
492
+ /**
493
+ * The maximum length of the internal buffer. If a write
494
+ * operation would cause the buffer to exceed `maxLength`, the data written is
495
+ * dropped and a drop event is emitted with the dropped data
496
+ */
497
+ maxLength?: number | undefined;
498
+ /**
499
+ * The maximum number of bytes that can be written;
500
+ * @default 16384
501
+ */
502
+ maxWrite?: number | undefined;
503
+ /**
504
+ * The minimum length of the internal buffer that is
505
+ * required to be full before flushing.
506
+ */
507
+ minLength?: number | undefined;
508
+ /**
509
+ * Ensure directory for `dest` file exists when true.
510
+ * @default false
511
+ */
512
+ mkdir?: boolean | undefined;
513
+ /**
514
+ * Specify the creating file mode (see `fs.open()`).
515
+ */
516
+ mode?: number | string | undefined;
517
+ /**
518
+ * Calls flush every `periodicFlush` milliseconds.
519
+ */
520
+ periodicFlush?: number | undefined;
521
+ /**
522
+ * A function that will be called when `write()`,
523
+ * `writeSync()`, or `flushSync()` encounters an `EAGAIN` or `EBUSY` error.
524
+ * If the return value is `true` the operation will be retried, otherwise it
525
+ * will bubble the error. The `err` is the error that caused this function to
526
+ * be called, `writeBufferLen` is the length of the buffer that was written,
527
+ * and `remainingBufferLen` is the length of the remaining buffer that the
528
+ * stream did not try to write.
529
+ */
530
+ retryEAGAIN?: ((err: Error | null, writeBufferLen: number, remainingBufferLen: number) => boolean) | undefined;
531
+ /**
532
+ * Perform writes synchronously.
533
+ */
534
+ sync?: boolean | undefined;
535
+ }
536
+ /**
537
+ * An optimized UTF-8 stream writer that allows for flushing all the internal
538
+ * buffering on demand. It handles `EAGAIN` errors correctly, allowing for
539
+ * customization, for example, by dropping content if the disk is busy.
540
+ * @since v24.6.0
541
+ * @experimental
542
+ */
543
+ export class Utf8Stream extends EventEmitter {
544
+ constructor(options: Utf8StreamOptions);
545
+ /**
546
+ * Whether the stream is appending to the file or truncating it.
547
+ */
548
+ readonly append: boolean;
549
+ /**
550
+ * The type of data that can be written to the stream. Supported
551
+ * values are `'utf8'` or `'buffer'`.
552
+ * @default 'utf8'
553
+ */
554
+ readonly contentMode: "utf8" | "buffer";
555
+ /**
556
+ * Close the stream immediately, without flushing the internal buffer.
557
+ */
558
+ destroy(): void;
559
+ /**
560
+ * Close the stream gracefully, flushing the internal buffer before closing.
561
+ */
562
+ end(): void;
563
+ /**
564
+ * The file descriptor that is being written to.
565
+ */
566
+ readonly fd: number;
567
+ /**
568
+ * The file that is being written to.
569
+ */
570
+ readonly file: string;
571
+ /**
572
+ * Writes the current buffer to the file if a write was not in progress. Do
573
+ * nothing if `minLength` is zero or if it is already writing.
574
+ */
575
+ flush(callback: (err: Error | null) => void): void;
576
+ /**
577
+ * Flushes the buffered data synchronously. This is a costly operation.
578
+ */
579
+ flushSync(): void;
580
+ /**
581
+ * Whether the stream is performing a `fs.fsyncSync()` after every
582
+ * write operation.
583
+ */
584
+ readonly fsync: boolean;
585
+ /**
586
+ * The maximum length of the internal buffer. If a write
587
+ * operation would cause the buffer to exceed `maxLength`, the data written is
588
+ * dropped and a drop event is emitted with the dropped data.
589
+ */
590
+ readonly maxLength: number;
591
+ /**
592
+ * The minimum length of the internal buffer that is required to be
593
+ * full before flushing.
594
+ */
595
+ readonly minLength: number;
596
+ /**
597
+ * Whether the stream should ensure that the directory for the
598
+ * `dest` file exists. If `true`, it will create the directory if it does not
599
+ * exist.
600
+ * @default false
601
+ */
602
+ readonly mkdir: boolean;
603
+ /**
604
+ * The mode of the file that is being written to.
605
+ */
606
+ readonly mode: number | string;
607
+ /**
608
+ * The number of milliseconds between flushes. If set to `0`, no
609
+ * periodic flushes will be performed.
610
+ */
611
+ readonly periodicFlush: number;
612
+ /**
613
+ * Reopen the file in place, useful for log rotation.
614
+ * @param file A path to a file to be written to (mode
615
+ * controlled by the append option).
616
+ */
617
+ reopen(file: PathLike): void;
618
+ /**
619
+ * Whether the stream is writing synchronously or asynchronously.
620
+ */
621
+ readonly sync: boolean;
622
+ /**
623
+ * When the `options.contentMode` is set to `'utf8'` when the stream is created,
624
+ * the `data` argument must be a string. If the `contentMode` is set to `'buffer'`,
625
+ * the `data` argument must be a `Buffer`.
626
+ * @param data The data to write.
627
+ */
628
+ write(data: string | Buffer): boolean;
629
+ /**
630
+ * Whether the stream is currently writing data to the file.
631
+ */
632
+ readonly writing: boolean;
633
+ /**
634
+ * Calls `utf8Stream.destroy()`.
635
+ */
636
+ [Symbol.dispose](): void;
637
+ /**
638
+ * events.EventEmitter
639
+ * 1. change
640
+ * 2. close
641
+ * 3. error
642
+ */
643
+ addListener(event: "close", listener: () => void): this;
644
+ addListener(event: "drain", listener: () => void): this;
645
+ addListener(event: "drop", listener: (data: string | Buffer) => void): this;
646
+ addListener(event: "error", listener: (error: Error) => void): this;
647
+ addListener(event: "finish", listener: () => void): this;
648
+ addListener(event: "ready", listener: () => void): this;
649
+ addListener(event: "write", listener: (n: number) => void): this;
650
+ addListener(event: string, listener: (...args: any[]) => void): this;
651
+ on(event: "close", listener: () => void): this;
652
+ on(event: "drain", listener: () => void): this;
653
+ on(event: "drop", listener: (data: string | Buffer) => void): this;
654
+ on(event: "error", listener: (error: Error) => void): this;
655
+ on(event: "finish", listener: () => void): this;
656
+ on(event: "ready", listener: () => void): this;
657
+ on(event: "write", listener: (n: number) => void): this;
658
+ on(event: string, listener: (...args: any[]) => void): this;
659
+ once(event: "close", listener: () => void): this;
660
+ once(event: "drain", listener: () => void): this;
661
+ once(event: "drop", listener: (data: string | Buffer) => void): this;
662
+ once(event: "error", listener: (error: Error) => void): this;
663
+ once(event: "finish", listener: () => void): this;
664
+ once(event: "ready", listener: () => void): this;
665
+ once(event: "write", listener: (n: number) => void): this;
666
+ once(event: string, listener: (...args: any[]) => void): this;
667
+ prependListener(event: "close", listener: () => void): this;
668
+ prependListener(event: "drain", listener: () => void): this;
669
+ prependListener(event: "drop", listener: (data: string | Buffer) => void): this;
670
+ prependListener(event: "error", listener: (error: Error) => void): this;
671
+ prependListener(event: "finish", listener: () => void): this;
672
+ prependListener(event: "ready", listener: () => void): this;
673
+ prependListener(event: "write", listener: (n: number) => void): this;
674
+ prependListener(event: string, listener: (...args: any[]) => void): this;
675
+ prependOnceListener(event: "close", listener: () => void): this;
676
+ prependOnceListener(event: "drain", listener: () => void): this;
677
+ prependOnceListener(event: "drop", listener: (data: string | Buffer) => void): this;
678
+ prependOnceListener(event: "error", listener: (error: Error) => void): this;
679
+ prependOnceListener(event: "finish", listener: () => void): this;
680
+ prependOnceListener(event: "ready", listener: () => void): this;
681
+ prependOnceListener(event: "write", listener: (n: number) => void): this;
682
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
683
+ }
461
684
 
462
685
  /**
463
686
  * The Keys are events of the ReadStream and the values are the functions that are called when the event is emitted.
@@ -1334,7 +1557,7 @@ declare module "fs" {
1334
1557
  export function readlink(
1335
1558
  path: PathLike,
1336
1559
  options: BufferEncodingOption,
1337
- callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void,
1560
+ callback: (err: NodeJS.ErrnoException | null, linkString: NonSharedBuffer) => void,
1338
1561
  ): void;
1339
1562
  /**
1340
1563
  * Asynchronous readlink(2) - read value of a symbolic link.
@@ -1344,7 +1567,7 @@ declare module "fs" {
1344
1567
  export function readlink(
1345
1568
  path: PathLike,
1346
1569
  options: EncodingOption,
1347
- callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void,
1570
+ callback: (err: NodeJS.ErrnoException | null, linkString: string | NonSharedBuffer) => void,
1348
1571
  ): void;
1349
1572
  /**
1350
1573
  * Asynchronous readlink(2) - read value of a symbolic link.
@@ -1366,13 +1589,13 @@ declare module "fs" {
1366
1589
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1367
1590
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1368
1591
  */
1369
- function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
1592
+ function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
1370
1593
  /**
1371
1594
  * Asynchronous readlink(2) - read value of a symbolic link.
1372
1595
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1373
1596
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1374
1597
  */
1375
- function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
1598
+ function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | NonSharedBuffer>;
1376
1599
  }
1377
1600
  /**
1378
1601
  * Returns the symbolic link's string value.
@@ -1391,13 +1614,13 @@ declare module "fs" {
1391
1614
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1392
1615
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1393
1616
  */
1394
- export function readlinkSync(path: PathLike, options: BufferEncodingOption): Buffer;
1617
+ export function readlinkSync(path: PathLike, options: BufferEncodingOption): NonSharedBuffer;
1395
1618
  /**
1396
1619
  * Synchronous readlink(2) - read value of a symbolic link.
1397
1620
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1398
1621
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1399
1622
  */
1400
- export function readlinkSync(path: PathLike, options?: EncodingOption): string | Buffer;
1623
+ export function readlinkSync(path: PathLike, options?: EncodingOption): string | NonSharedBuffer;
1401
1624
  /**
1402
1625
  * Asynchronously computes the canonical pathname by resolving `.`, `..`, and
1403
1626
  * symbolic links.
@@ -1437,7 +1660,7 @@ declare module "fs" {
1437
1660
  export function realpath(
1438
1661
  path: PathLike,
1439
1662
  options: BufferEncodingOption,
1440
- callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void,
1663
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: NonSharedBuffer) => void,
1441
1664
  ): void;
1442
1665
  /**
1443
1666
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
@@ -1447,7 +1670,7 @@ declare module "fs" {
1447
1670
  export function realpath(
1448
1671
  path: PathLike,
1449
1672
  options: EncodingOption,
1450
- callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void,
1673
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | NonSharedBuffer) => void,
1451
1674
  ): void;
1452
1675
  /**
1453
1676
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
@@ -1469,13 +1692,13 @@ declare module "fs" {
1469
1692
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1470
1693
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1471
1694
  */
1472
- function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
1695
+ function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
1473
1696
  /**
1474
1697
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1475
1698
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1476
1699
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1477
1700
  */
1478
- function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
1701
+ function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | NonSharedBuffer>;
1479
1702
  /**
1480
1703
  * Asynchronous [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html).
1481
1704
  *
@@ -1501,12 +1724,12 @@ declare module "fs" {
1501
1724
  function native(
1502
1725
  path: PathLike,
1503
1726
  options: BufferEncodingOption,
1504
- callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void,
1727
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: NonSharedBuffer) => void,
1505
1728
  ): void;
1506
1729
  function native(
1507
1730
  path: PathLike,
1508
1731
  options: EncodingOption,
1509
- callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void,
1732
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | NonSharedBuffer) => void,
1510
1733
  ): void;
1511
1734
  function native(
1512
1735
  path: PathLike,
@@ -1526,17 +1749,17 @@ declare module "fs" {
1526
1749
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1527
1750
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1528
1751
  */
1529
- export function realpathSync(path: PathLike, options: BufferEncodingOption): Buffer;
1752
+ export function realpathSync(path: PathLike, options: BufferEncodingOption): NonSharedBuffer;
1530
1753
  /**
1531
1754
  * Synchronous realpath(3) - return the canonicalized absolute pathname.
1532
1755
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1533
1756
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1534
1757
  */
1535
- export function realpathSync(path: PathLike, options?: EncodingOption): string | Buffer;
1758
+ export function realpathSync(path: PathLike, options?: EncodingOption): string | NonSharedBuffer;
1536
1759
  export namespace realpathSync {
1537
1760
  function native(path: PathLike, options?: EncodingOption): string;
1538
- function native(path: PathLike, options: BufferEncodingOption): Buffer;
1539
- function native(path: PathLike, options?: EncodingOption): string | Buffer;
1761
+ function native(path: PathLike, options: BufferEncodingOption): NonSharedBuffer;
1762
+ function native(path: PathLike, options?: EncodingOption): string | NonSharedBuffer;
1540
1763
  }
1541
1764
  /**
1542
1765
  * Asynchronously removes a file or symbolic link. No arguments other than a
@@ -1906,12 +2129,8 @@ declare module "fs" {
1906
2129
  */
1907
2130
  export function mkdtemp(
1908
2131
  prefix: string,
1909
- options:
1910
- | "buffer"
1911
- | {
1912
- encoding: "buffer";
1913
- },
1914
- callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void,
2132
+ options: BufferEncodingOption,
2133
+ callback: (err: NodeJS.ErrnoException | null, folder: NonSharedBuffer) => void,
1915
2134
  ): void;
1916
2135
  /**
1917
2136
  * Asynchronously creates a unique temporary directory.
@@ -1921,7 +2140,7 @@ declare module "fs" {
1921
2140
  export function mkdtemp(
1922
2141
  prefix: string,
1923
2142
  options: EncodingOption,
1924
- callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void,
2143
+ callback: (err: NodeJS.ErrnoException | null, folder: string | NonSharedBuffer) => void,
1925
2144
  ): void;
1926
2145
  /**
1927
2146
  * Asynchronously creates a unique temporary directory.
@@ -1943,13 +2162,13 @@ declare module "fs" {
1943
2162
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1944
2163
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1945
2164
  */
1946
- function __promisify__(prefix: string, options: BufferEncodingOption): Promise<Buffer>;
2165
+ function __promisify__(prefix: string, options: BufferEncodingOption): Promise<NonSharedBuffer>;
1947
2166
  /**
1948
2167
  * Asynchronously creates a unique temporary directory.
1949
2168
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1950
2169
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1951
2170
  */
1952
- function __promisify__(prefix: string, options?: EncodingOption): Promise<string | Buffer>;
2171
+ function __promisify__(prefix: string, options?: EncodingOption): Promise<string | NonSharedBuffer>;
1953
2172
  }
1954
2173
  /**
1955
2174
  * Returns the created directory path.
@@ -1967,13 +2186,46 @@ declare module "fs" {
1967
2186
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1968
2187
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1969
2188
  */
1970
- export function mkdtempSync(prefix: string, options: BufferEncodingOption): Buffer;
2189
+ export function mkdtempSync(prefix: string, options: BufferEncodingOption): NonSharedBuffer;
1971
2190
  /**
1972
2191
  * Synchronously creates a unique temporary directory.
1973
2192
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1974
2193
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1975
2194
  */
1976
- export function mkdtempSync(prefix: string, options?: EncodingOption): string | Buffer;
2195
+ export function mkdtempSync(prefix: string, options?: EncodingOption): string | NonSharedBuffer;
2196
+ export interface DisposableTempDir extends AsyncDisposable {
2197
+ /**
2198
+ * The path of the created directory.
2199
+ */
2200
+ path: string;
2201
+ /**
2202
+ * A function which removes the created directory.
2203
+ */
2204
+ remove(): Promise<void>;
2205
+ /**
2206
+ * The same as `remove`.
2207
+ */
2208
+ [Symbol.asyncDispose](): Promise<void>;
2209
+ }
2210
+ /**
2211
+ * Returns a disposable object whose `path` property holds the created directory
2212
+ * path. When the object is disposed, the directory and its contents will be
2213
+ * removed if it still exists. If the directory cannot be deleted, disposal will
2214
+ * throw an error. The object has a `remove()` method which will perform the same
2215
+ * task.
2216
+ *
2217
+ * <!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
2218
+ *
2219
+ * For detailed information, see the documentation of `fs.mkdtemp()`.
2220
+ *
2221
+ * There is no callback-based version of this API because it is designed for use
2222
+ * with the `using` syntax.
2223
+ *
2224
+ * The optional `options` argument can be a string specifying an encoding, or an
2225
+ * object with an `encoding` property specifying the character encoding to use.
2226
+ * @since v24.4.0
2227
+ */
2228
+ export function mkdtempDisposableSync(prefix: string, options?: EncodingOption): DisposableTempDir;
1977
2229
  /**
1978
2230
  * Reads the contents of a directory. The callback gets two arguments `(err, files)` where `files` is an array of the names of the files in the directory excluding `'.'` and `'..'`.
1979
2231
  *
@@ -2014,7 +2266,7 @@ declare module "fs" {
2014
2266
  recursive?: boolean | undefined;
2015
2267
  }
2016
2268
  | "buffer",
2017
- callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void,
2269
+ callback: (err: NodeJS.ErrnoException | null, files: NonSharedBuffer[]) => void,
2018
2270
  ): void;
2019
2271
  /**
2020
2272
  * Asynchronous readdir(3) - read a directory.
@@ -2031,7 +2283,7 @@ declare module "fs" {
2031
2283
  | BufferEncoding
2032
2284
  | undefined
2033
2285
  | null,
2034
- callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void,
2286
+ callback: (err: NodeJS.ErrnoException | null, files: string[] | NonSharedBuffer[]) => void,
2035
2287
  ): void;
2036
2288
  /**
2037
2289
  * Asynchronous readdir(3) - read a directory.
@@ -2066,7 +2318,7 @@ declare module "fs" {
2066
2318
  withFileTypes: true;
2067
2319
  recursive?: boolean | undefined;
2068
2320
  },
2069
- callback: (err: NodeJS.ErrnoException | null, files: Dirent<Buffer>[]) => void,
2321
+ callback: (err: NodeJS.ErrnoException | null, files: Dirent<NonSharedBuffer>[]) => void,
2070
2322
  ): void;
2071
2323
  export namespace readdir {
2072
2324
  /**
@@ -2099,7 +2351,7 @@ declare module "fs" {
2099
2351
  withFileTypes?: false | undefined;
2100
2352
  recursive?: boolean | undefined;
2101
2353
  },
2102
- ): Promise<Buffer[]>;
2354
+ ): Promise<NonSharedBuffer[]>;
2103
2355
  /**
2104
2356
  * Asynchronous readdir(3) - read a directory.
2105
2357
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -2114,7 +2366,7 @@ declare module "fs" {
2114
2366
  })
2115
2367
  | BufferEncoding
2116
2368
  | null,
2117
- ): Promise<string[] | Buffer[]>;
2369
+ ): Promise<string[] | NonSharedBuffer[]>;
2118
2370
  /**
2119
2371
  * Asynchronous readdir(3) - read a directory.
2120
2372
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -2139,7 +2391,7 @@ declare module "fs" {
2139
2391
  withFileTypes: true;
2140
2392
  recursive?: boolean | undefined;
2141
2393
  },
2142
- ): Promise<Dirent<Buffer>[]>;
2394
+ ): Promise<Dirent<NonSharedBuffer>[]>;
2143
2395
  }
2144
2396
  /**
2145
2397
  * Reads the contents of the directory.
@@ -2179,7 +2431,7 @@ declare module "fs" {
2179
2431
  recursive?: boolean | undefined;
2180
2432
  }
2181
2433
  | "buffer",
2182
- ): Buffer[];
2434
+ ): NonSharedBuffer[];
2183
2435
  /**
2184
2436
  * Synchronous readdir(3) - read a directory.
2185
2437
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -2194,7 +2446,7 @@ declare module "fs" {
2194
2446
  })
2195
2447
  | BufferEncoding
2196
2448
  | null,
2197
- ): string[] | Buffer[];
2449
+ ): string[] | NonSharedBuffer[];
2198
2450
  /**
2199
2451
  * Synchronous readdir(3) - read a directory.
2200
2452
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -2219,7 +2471,7 @@ declare module "fs" {
2219
2471
  withFileTypes: true;
2220
2472
  recursive?: boolean | undefined;
2221
2473
  },
2222
- ): Dirent<Buffer>[];
2474
+ ): Dirent<NonSharedBuffer>[];
2223
2475
  /**
2224
2476
  * Closes the file descriptor. No arguments other than a possible exception are
2225
2477
  * given to the completion callback.
@@ -2385,7 +2637,7 @@ declare module "fs" {
2385
2637
  /**
2386
2638
  * @default null
2387
2639
  */
2388
- position?: number | undefined | null;
2640
+ position?: number | null | undefined;
2389
2641
  }
2390
2642
  /**
2391
2643
  * Write `buffer` to the file specified by `fd`.
@@ -2586,7 +2838,7 @@ declare module "fs" {
2586
2838
  encoding?: BufferEncoding | null,
2587
2839
  ): number;
2588
2840
  export type ReadPosition = number | bigint;
2589
- export interface ReadSyncOptions {
2841
+ export interface ReadOptions {
2590
2842
  /**
2591
2843
  * @default 0
2592
2844
  */
@@ -2600,9 +2852,15 @@ declare module "fs" {
2600
2852
  */
2601
2853
  position?: ReadPosition | null | undefined;
2602
2854
  }
2603
- export interface ReadAsyncOptions<TBuffer extends NodeJS.ArrayBufferView> extends ReadSyncOptions {
2604
- buffer?: TBuffer;
2855
+ export interface ReadOptionsWithBuffer<T extends NodeJS.ArrayBufferView> extends ReadOptions {
2856
+ buffer?: T | undefined;
2605
2857
  }
2858
+ /** @deprecated Use `ReadOptions` instead. */
2859
+ // TODO: remove in future major
2860
+ export interface ReadSyncOptions extends ReadOptions {}
2861
+ /** @deprecated Use `ReadOptionsWithBuffer` instead. */
2862
+ // TODO: remove in future major
2863
+ export interface ReadAsyncOptions<T extends NodeJS.ArrayBufferView> extends ReadOptionsWithBuffer<T> {}
2606
2864
  /**
2607
2865
  * Read data from the file specified by `fd`.
2608
2866
  *
@@ -2637,15 +2895,15 @@ declare module "fs" {
2637
2895
  * `position` defaults to `null`
2638
2896
  * @since v12.17.0, 13.11.0
2639
2897
  */
2640
- export function read<TBuffer extends NodeJS.ArrayBufferView>(
2898
+ export function read<TBuffer extends NodeJS.ArrayBufferView = NonSharedBuffer>(
2641
2899
  fd: number,
2642
- options: ReadAsyncOptions<TBuffer>,
2900
+ options: ReadOptionsWithBuffer<TBuffer>,
2643
2901
  callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
2644
2902
  ): void;
2645
2903
  export function read<TBuffer extends NodeJS.ArrayBufferView>(
2646
2904
  fd: number,
2647
2905
  buffer: TBuffer,
2648
- options: ReadSyncOptions,
2906
+ options: ReadOptions,
2649
2907
  callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
2650
2908
  ): void;
2651
2909
  export function read<TBuffer extends NodeJS.ArrayBufferView>(
@@ -2655,7 +2913,7 @@ declare module "fs" {
2655
2913
  ): void;
2656
2914
  export function read(
2657
2915
  fd: number,
2658
- callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void,
2916
+ callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NonSharedBuffer) => void,
2659
2917
  ): void;
2660
2918
  export namespace read {
2661
2919
  /**
@@ -2675,16 +2933,16 @@ declare module "fs" {
2675
2933
  bytesRead: number;
2676
2934
  buffer: TBuffer;
2677
2935
  }>;
2678
- function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
2936
+ function __promisify__<TBuffer extends NodeJS.ArrayBufferView = NonSharedBuffer>(
2679
2937
  fd: number,
2680
- options: ReadAsyncOptions<TBuffer>,
2938
+ options: ReadOptionsWithBuffer<TBuffer>,
2681
2939
  ): Promise<{
2682
2940
  bytesRead: number;
2683
2941
  buffer: TBuffer;
2684
2942
  }>;
2685
2943
  function __promisify__(fd: number): Promise<{
2686
2944
  bytesRead: number;
2687
- buffer: NodeJS.ArrayBufferView;
2945
+ buffer: NonSharedBuffer;
2688
2946
  }>;
2689
2947
  }
2690
2948
  /**
@@ -2706,7 +2964,7 @@ declare module "fs" {
2706
2964
  * Similar to the above `fs.readSync` function, this version takes an optional `options` object.
2707
2965
  * If no `options` object is specified, it will default with the above values.
2708
2966
  */
2709
- export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadSyncOptions): number;
2967
+ export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadOptions): number;
2710
2968
  /**
2711
2969
  * Asynchronously reads the entire contents of a file.
2712
2970
  *
@@ -3379,12 +3637,12 @@ declare module "fs" {
3379
3637
  export function watch(
3380
3638
  filename: PathLike,
3381
3639
  options: WatchOptionsWithBufferEncoding | "buffer",
3382
- listener: WatchListener<Buffer>,
3640
+ listener: WatchListener<NonSharedBuffer>,
3383
3641
  ): FSWatcher;
3384
3642
  export function watch(
3385
3643
  filename: PathLike,
3386
3644
  options: WatchOptions | BufferEncoding | "buffer" | null,
3387
- listener: WatchListener<string | Buffer>,
3645
+ listener: WatchListener<string | NonSharedBuffer>,
3388
3646
  ): FSWatcher;
3389
3647
  export function watch(filename: PathLike, listener: WatchListener<string>): FSWatcher;
3390
3648
  /**
@@ -4095,27 +4353,29 @@ declare module "fs" {
4095
4353
  * @since v12.9.0
4096
4354
  * @param [position='null']
4097
4355
  */
4098
- export function writev(
4356
+ export function writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4099
4357
  fd: number,
4100
- buffers: readonly NodeJS.ArrayBufferView[],
4101
- cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void,
4358
+ buffers: TBuffers,
4359
+ cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: TBuffers) => void,
4102
4360
  ): void;
4103
- export function writev(
4361
+ export function writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4104
4362
  fd: number,
4105
- buffers: readonly NodeJS.ArrayBufferView[],
4363
+ buffers: TBuffers,
4106
4364
  position: number | null,
4107
- cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void,
4365
+ cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: TBuffers) => void,
4108
4366
  ): void;
4109
- export interface WriteVResult {
4367
+ // Providing a default type parameter doesn't provide true BC for userland consumers, but at least suppresses TS2314
4368
+ // TODO: remove default in future major version
4369
+ export interface WriteVResult<T extends readonly NodeJS.ArrayBufferView[] = NodeJS.ArrayBufferView[]> {
4110
4370
  bytesWritten: number;
4111
- buffers: NodeJS.ArrayBufferView[];
4371
+ buffers: T;
4112
4372
  }
4113
4373
  export namespace writev {
4114
- function __promisify__(
4374
+ function __promisify__<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4115
4375
  fd: number,
4116
- buffers: readonly NodeJS.ArrayBufferView[],
4376
+ buffers: TBuffers,
4117
4377
  position?: number,
4118
- ): Promise<WriteVResult>;
4378
+ ): Promise<WriteVResult<TBuffers>>;
4119
4379
  }
4120
4380
  /**
4121
4381
  * For detailed information, see the documentation of the asynchronous version of
@@ -4140,27 +4400,29 @@ declare module "fs" {
4140
4400
  * @since v13.13.0, v12.17.0
4141
4401
  * @param [position='null']
4142
4402
  */
4143
- export function readv(
4403
+ export function readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4144
4404
  fd: number,
4145
- buffers: readonly NodeJS.ArrayBufferView[],
4146
- cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void,
4405
+ buffers: TBuffers,
4406
+ cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: TBuffers) => void,
4147
4407
  ): void;
4148
- export function readv(
4408
+ export function readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4149
4409
  fd: number,
4150
- buffers: readonly NodeJS.ArrayBufferView[],
4410
+ buffers: TBuffers,
4151
4411
  position: number | null,
4152
- cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void,
4412
+ cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: TBuffers) => void,
4153
4413
  ): void;
4154
- export interface ReadVResult {
4414
+ // Providing a default type parameter doesn't provide true BC for userland consumers, but at least suppresses TS2314
4415
+ // TODO: remove default in future major version
4416
+ export interface ReadVResult<T extends readonly NodeJS.ArrayBufferView[] = NodeJS.ArrayBufferView[]> {
4155
4417
  bytesRead: number;
4156
- buffers: NodeJS.ArrayBufferView[];
4418
+ buffers: T;
4157
4419
  }
4158
4420
  export namespace readv {
4159
- function __promisify__(
4421
+ function __promisify__<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4160
4422
  fd: number,
4161
- buffers: readonly NodeJS.ArrayBufferView[],
4423
+ buffers: TBuffers,
4162
4424
  position?: number,
4163
- ): Promise<ReadVResult>;
4425
+ ): Promise<ReadVResult<TBuffers>>;
4164
4426
  }
4165
4427
  /**
4166
4428
  * For detailed information, see the documentation of the asynchronous version of
@@ -4214,7 +4476,7 @@ declare module "fs" {
4214
4476
  /**
4215
4477
  * @default false
4216
4478
  */
4217
- recursive?: boolean;
4479
+ recursive?: boolean | undefined;
4218
4480
  }
4219
4481
  /**
4220
4482
  * Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html).
@@ -4267,54 +4529,54 @@ declare module "fs" {
4267
4529
  * Dereference symlinks
4268
4530
  * @default false
4269
4531
  */
4270
- dereference?: boolean;
4532
+ dereference?: boolean | undefined;
4271
4533
  /**
4272
4534
  * When `force` is `false`, and the destination
4273
4535
  * exists, throw an error.
4274
4536
  * @default false
4275
4537
  */
4276
- errorOnExist?: boolean;
4538
+ errorOnExist?: boolean | undefined;
4277
4539
  /**
4278
4540
  * Overwrite existing file or directory. _The copy
4279
4541
  * operation will ignore errors if you set this to false and the destination
4280
4542
  * exists. Use the `errorOnExist` option to change this behavior.
4281
4543
  * @default true
4282
4544
  */
4283
- force?: boolean;
4545
+ force?: boolean | undefined;
4284
4546
  /**
4285
4547
  * Modifiers for copy operation. See `mode` flag of {@link copyFileSync()}
4286
4548
  */
4287
- mode?: number;
4549
+ mode?: number | undefined;
4288
4550
  /**
4289
4551
  * When `true` timestamps from `src` will
4290
4552
  * be preserved.
4291
4553
  * @default false
4292
4554
  */
4293
- preserveTimestamps?: boolean;
4555
+ preserveTimestamps?: boolean | undefined;
4294
4556
  /**
4295
4557
  * Copy directories recursively.
4296
4558
  * @default false
4297
4559
  */
4298
- recursive?: boolean;
4560
+ recursive?: boolean | undefined;
4299
4561
  /**
4300
4562
  * When true, path resolution for symlinks will be skipped
4301
4563
  * @default false
4302
4564
  */
4303
- verbatimSymlinks?: boolean;
4565
+ verbatimSymlinks?: boolean | undefined;
4304
4566
  }
4305
4567
  export interface CopyOptions extends CopyOptionsBase {
4306
4568
  /**
4307
4569
  * Function to filter copied files/directories. Return
4308
4570
  * `true` to copy the item, `false` to ignore it.
4309
4571
  */
4310
- filter?(source: string, destination: string): boolean | Promise<boolean>;
4572
+ filter?: ((source: string, destination: string) => boolean | Promise<boolean>) | undefined;
4311
4573
  }
4312
4574
  export interface CopySyncOptions extends CopyOptionsBase {
4313
4575
  /**
4314
4576
  * Function to filter copied files/directories. Return
4315
4577
  * `true` to copy the item, `false` to ignore it.
4316
4578
  */
4317
- filter?(source: string, destination: string): boolean;
4579
+ filter?: ((source: string, destination: string) => boolean) | undefined;
4318
4580
  }
4319
4581
  /**
4320
4582
  * Asynchronously copies the entire directory structure from `src` to `dest`,
@@ -4351,6 +4613,7 @@ declare module "fs" {
4351
4613
  */
4352
4614
  export function cpSync(source: string | URL, destination: string | URL, opts?: CopySyncOptions): void;
4353
4615
 
4616
+ // TODO: collapse
4354
4617
  interface _GlobOptions<T extends Dirent | string> {
4355
4618
  /**
4356
4619
  * Current working directory.
@@ -4367,6 +4630,9 @@ declare module "fs" {
4367
4630
  * Function to filter out files/directories or a
4368
4631
  * list of glob patterns to be excluded. If a function is provided, return
4369
4632
  * `true` to exclude the item, `false` to include it.
4633
+ * If a string array is provided, each string should be a glob pattern that
4634
+ * specifies paths to exclude. Note: Negation patterns (e.g., '!foo.js') are
4635
+ * not supported.
4370
4636
  * @default undefined
4371
4637
  */
4372
4638
  exclude?: ((fileName: T) => boolean) | readonly string[] | undefined;