@types/node 20.19.22 → 20.19.24

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 v20.19/dgram.d.ts CHANGED
@@ -26,6 +26,7 @@
26
26
  * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/dgram.js)
27
27
  */
28
28
  declare module "dgram" {
29
+ import { NonSharedBuffer } from "node:buffer";
29
30
  import { AddressInfo } from "node:net";
30
31
  import * as dns from "node:dns";
31
32
  import { Abortable, EventEmitter } from "node:events";
@@ -82,8 +83,8 @@ declare module "dgram" {
82
83
  * @param options Available options are:
83
84
  * @param callback Attached as a listener for `'message'` events. Optional.
84
85
  */
85
- function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
86
- function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
86
+ function createSocket(type: SocketType, callback?: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): Socket;
87
+ function createSocket(options: SocketOptions, callback?: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): Socket;
87
88
  /**
88
89
  * Encapsulates the datagram functionality.
89
90
  *
@@ -553,37 +554,37 @@ declare module "dgram" {
553
554
  addListener(event: "connect", listener: () => void): this;
554
555
  addListener(event: "error", listener: (err: Error) => void): this;
555
556
  addListener(event: "listening", listener: () => void): this;
556
- addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
557
+ addListener(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
557
558
  emit(event: string | symbol, ...args: any[]): boolean;
558
559
  emit(event: "close"): boolean;
559
560
  emit(event: "connect"): boolean;
560
561
  emit(event: "error", err: Error): boolean;
561
562
  emit(event: "listening"): boolean;
562
- emit(event: "message", msg: Buffer, rinfo: RemoteInfo): boolean;
563
+ emit(event: "message", msg: NonSharedBuffer, rinfo: RemoteInfo): boolean;
563
564
  on(event: string, listener: (...args: any[]) => void): this;
564
565
  on(event: "close", listener: () => void): this;
565
566
  on(event: "connect", listener: () => void): this;
566
567
  on(event: "error", listener: (err: Error) => void): this;
567
568
  on(event: "listening", listener: () => void): this;
568
- on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
569
+ on(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
569
570
  once(event: string, listener: (...args: any[]) => void): this;
570
571
  once(event: "close", listener: () => void): this;
571
572
  once(event: "connect", listener: () => void): this;
572
573
  once(event: "error", listener: (err: Error) => void): this;
573
574
  once(event: "listening", listener: () => void): this;
574
- once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
575
+ once(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
575
576
  prependListener(event: string, listener: (...args: any[]) => void): this;
576
577
  prependListener(event: "close", listener: () => void): this;
577
578
  prependListener(event: "connect", listener: () => void): this;
578
579
  prependListener(event: "error", listener: (err: Error) => void): this;
579
580
  prependListener(event: "listening", listener: () => void): this;
580
- prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
581
+ prependListener(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
581
582
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
582
583
  prependOnceListener(event: "close", listener: () => void): this;
583
584
  prependOnceListener(event: "connect", listener: () => void): this;
584
585
  prependOnceListener(event: "error", listener: (err: Error) => void): this;
585
586
  prependOnceListener(event: "listening", listener: () => void): this;
586
- prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
587
+ prependOnceListener(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
587
588
  /**
588
589
  * Calls `socket.close()` and returns a promise that fulfills when the socket has closed.
589
590
  * @since v20.5.0
@@ -9,6 +9,7 @@
9
9
  * @since v10.0.0
10
10
  */
11
11
  declare module "fs/promises" {
12
+ import { NonSharedBuffer } from "node:buffer";
12
13
  import { Abortable } from "node:events";
13
14
  import { Stream } from "node:stream";
14
15
  import { ReadableStream } from "node:stream/web";
@@ -26,6 +27,8 @@ declare module "fs/promises" {
26
27
  OpenDirOptions,
27
28
  OpenMode,
28
29
  PathLike,
30
+ ReadOptions,
31
+ ReadOptionsWithBuffer,
29
32
  ReadStream,
30
33
  ReadVResult,
31
34
  RmDirOptions,
@@ -53,6 +56,7 @@ declare module "fs/promises" {
53
56
  bytesRead: number;
54
57
  buffer: T;
55
58
  }
59
+ /** @deprecated This interface will be removed in a future version. Use `import { ReadOptionsWithBuffer } from "node:fs"` instead. */
56
60
  interface FileReadOptions<T extends NodeJS.ArrayBufferView = Buffer> {
57
61
  /**
58
62
  * @default `Buffer.alloc(0xffff)`
@@ -235,7 +239,13 @@ declare module "fs/promises" {
235
239
  length?: number | null,
236
240
  position?: number | null,
237
241
  ): Promise<FileReadResult<T>>;
238
- read<T extends NodeJS.ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
242
+ read<T extends NodeJS.ArrayBufferView>(
243
+ buffer: T,
244
+ options?: ReadOptions,
245
+ ): Promise<FileReadResult<T>>;
246
+ read<T extends NodeJS.ArrayBufferView = NonSharedBuffer>(
247
+ options?: ReadOptionsWithBuffer<T>,
248
+ ): Promise<FileReadResult<T>>;
239
249
  /**
240
250
  * Returns a `ReadableStream` that may be used to read the files data.
241
251
  *
@@ -279,7 +289,7 @@ declare module "fs/promises" {
279
289
  options?:
280
290
  | ({ encoding?: null | undefined } & Abortable)
281
291
  | null,
282
- ): Promise<Buffer>;
292
+ ): Promise<NonSharedBuffer>;
283
293
  /**
284
294
  * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
285
295
  * The `FileHandle` must have been opened for reading.
@@ -298,7 +308,7 @@ declare module "fs/promises" {
298
308
  | (ObjectEncodingOptions & Abortable)
299
309
  | BufferEncoding
300
310
  | null,
301
- ): Promise<string | Buffer>;
311
+ ): Promise<string | NonSharedBuffer>;
302
312
  /**
303
313
  * Convenience method to create a `readline` interface and stream over the file.
304
314
  * See `filehandle.createReadStream()` for the options.
@@ -407,7 +417,7 @@ declare module "fs/promises" {
407
417
  * @param [position='null'] The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current
408
418
  * position. See the POSIX pwrite(2) documentation for more detail.
409
419
  */
410
- write<TBuffer extends Uint8Array>(
420
+ write<TBuffer extends NodeJS.ArrayBufferView>(
411
421
  buffer: TBuffer,
412
422
  offset?: number | null,
413
423
  length?: number | null,
@@ -439,14 +449,20 @@ declare module "fs/promises" {
439
449
  * @param [position='null'] The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current
440
450
  * position.
441
451
  */
442
- writev(buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise<WriteVResult>;
452
+ writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
453
+ buffers: TBuffers,
454
+ position?: number,
455
+ ): Promise<WriteVResult<TBuffers>>;
443
456
  /**
444
457
  * Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s
445
458
  * @since v13.13.0, v12.17.0
446
459
  * @param [position='null'] The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position.
447
460
  * @return Fulfills upon success an object containing two properties:
448
461
  */
449
- readv(buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise<ReadVResult>;
462
+ readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
463
+ buffers: TBuffers,
464
+ position?: number,
465
+ ): Promise<ReadVResult<TBuffers>>;
450
466
  /**
451
467
  * Closes the file handle after waiting for any pending operation on the handle to
452
468
  * complete.
@@ -682,7 +698,7 @@ declare module "fs/promises" {
682
698
  recursive?: boolean | undefined;
683
699
  }
684
700
  | "buffer",
685
- ): Promise<Buffer[]>;
701
+ ): Promise<NonSharedBuffer[]>;
686
702
  /**
687
703
  * Asynchronous readdir(3) - read a directory.
688
704
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -697,7 +713,7 @@ declare module "fs/promises" {
697
713
  })
698
714
  | BufferEncoding
699
715
  | null,
700
- ): Promise<string[] | Buffer[]>;
716
+ ): Promise<string[] | NonSharedBuffer[]>;
701
717
  /**
702
718
  * Asynchronous readdir(3) - read a directory.
703
719
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -722,7 +738,7 @@ declare module "fs/promises" {
722
738
  withFileTypes: true;
723
739
  recursive?: boolean | undefined;
724
740
  },
725
- ): Promise<Dirent<Buffer>[]>;
741
+ ): Promise<Dirent<NonSharedBuffer>[]>;
726
742
  /**
727
743
  * Reads the contents of the symbolic link referred to by `path`. See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is
728
744
  * fulfilled with the`linkString` upon success.
@@ -740,13 +756,16 @@ declare module "fs/promises" {
740
756
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
741
757
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
742
758
  */
743
- function readlink(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
759
+ function readlink(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
744
760
  /**
745
761
  * Asynchronous readlink(2) - read value of a symbolic link.
746
762
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
747
763
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
748
764
  */
749
- function readlink(path: PathLike, options?: ObjectEncodingOptions | string | null): Promise<string | Buffer>;
765
+ function readlink(
766
+ path: PathLike,
767
+ options?: ObjectEncodingOptions | string | null,
768
+ ): Promise<string | NonSharedBuffer>;
750
769
  /**
751
770
  * Creates a symbolic link.
752
771
  *
@@ -897,7 +916,7 @@ declare module "fs/promises" {
897
916
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
898
917
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
899
918
  */
900
- function realpath(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
919
+ function realpath(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
901
920
  /**
902
921
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
903
922
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -906,7 +925,7 @@ declare module "fs/promises" {
906
925
  function realpath(
907
926
  path: PathLike,
908
927
  options?: ObjectEncodingOptions | BufferEncoding | null,
909
- ): Promise<string | Buffer>;
928
+ ): Promise<string | NonSharedBuffer>;
910
929
  /**
911
930
  * Creates a unique temporary directory. A unique directory name is generated by
912
931
  * appending six random characters to the end of the provided `prefix`. Due to
@@ -942,13 +961,16 @@ declare module "fs/promises" {
942
961
  * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
943
962
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
944
963
  */
945
- function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<Buffer>;
964
+ function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<NonSharedBuffer>;
946
965
  /**
947
966
  * Asynchronously creates a unique temporary directory.
948
967
  * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
949
968
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
950
969
  */
951
- function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
970
+ function mkdtemp(
971
+ prefix: string,
972
+ options?: ObjectEncodingOptions | BufferEncoding | null,
973
+ ): Promise<string | NonSharedBuffer>;
952
974
  /**
953
975
  * Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an
954
976
  * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an
@@ -1104,7 +1126,7 @@ declare module "fs/promises" {
1104
1126
  flag?: OpenMode | undefined;
1105
1127
  } & Abortable)
1106
1128
  | null,
1107
- ): Promise<Buffer>;
1129
+ ): Promise<NonSharedBuffer>;
1108
1130
  /**
1109
1131
  * Asynchronously reads the entire contents of a file.
1110
1132
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -1140,7 +1162,7 @@ declare module "fs/promises" {
1140
1162
  )
1141
1163
  | BufferEncoding
1142
1164
  | null,
1143
- ): Promise<string | Buffer>;
1165
+ ): Promise<string | NonSharedBuffer>;
1144
1166
  /**
1145
1167
  * 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.
1146
1168
  *
@@ -1207,7 +1229,7 @@ declare module "fs/promises" {
1207
1229
  encoding: "buffer";
1208
1230
  })
1209
1231
  | "buffer",
1210
- ): AsyncIterable<FileChangeInfo<Buffer>>;
1232
+ ): AsyncIterable<FileChangeInfo<NonSharedBuffer>>;
1211
1233
  /**
1212
1234
  * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1213
1235
  * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
@@ -1228,7 +1250,7 @@ declare module "fs/promises" {
1228
1250
  function watch(
1229
1251
  filename: PathLike,
1230
1252
  options: WatchOptions | string,
1231
- ): AsyncIterable<FileChangeInfo<string>> | AsyncIterable<FileChangeInfo<Buffer>>;
1253
+ ): AsyncIterable<FileChangeInfo<string>> | AsyncIterable<FileChangeInfo<NonSharedBuffer>>;
1232
1254
  /**
1233
1255
  * Asynchronously copies the entire directory structure from `src` to `dest`,
1234
1256
  * including subdirectories and files.