@types/node 22.18.11 → 22.18.12

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 v22.18/dgram.d.ts CHANGED
@@ -26,6 +26,7 @@
26
26
  * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/dgram.js)
27
27
  */
28
28
  declare module "dgram" {
29
+ import { NonSharedBuffer } from "node:buffer";
29
30
  import { AddressInfo, BlockList } from "node:net";
30
31
  import * as dns from "node:dns";
31
32
  import { Abortable, EventEmitter } from "node:events";
@@ -85,8 +86,8 @@ declare module "dgram" {
85
86
  * @param options Available options are:
86
87
  * @param callback Attached as a listener for `'message'` events. Optional.
87
88
  */
88
- function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
89
- function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
89
+ function createSocket(type: SocketType, callback?: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): Socket;
90
+ function createSocket(options: SocketOptions, callback?: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): Socket;
90
91
  /**
91
92
  * Encapsulates the datagram functionality.
92
93
  *
@@ -556,37 +557,37 @@ declare module "dgram" {
556
557
  addListener(event: "connect", listener: () => void): this;
557
558
  addListener(event: "error", listener: (err: Error) => void): this;
558
559
  addListener(event: "listening", listener: () => void): this;
559
- addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
560
+ addListener(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
560
561
  emit(event: string | symbol, ...args: any[]): boolean;
561
562
  emit(event: "close"): boolean;
562
563
  emit(event: "connect"): boolean;
563
564
  emit(event: "error", err: Error): boolean;
564
565
  emit(event: "listening"): boolean;
565
- emit(event: "message", msg: Buffer, rinfo: RemoteInfo): boolean;
566
+ emit(event: "message", msg: NonSharedBuffer, rinfo: RemoteInfo): boolean;
566
567
  on(event: string, listener: (...args: any[]) => void): this;
567
568
  on(event: "close", listener: () => void): this;
568
569
  on(event: "connect", listener: () => void): this;
569
570
  on(event: "error", listener: (err: Error) => void): this;
570
571
  on(event: "listening", listener: () => void): this;
571
- on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
572
+ on(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
572
573
  once(event: string, listener: (...args: any[]) => void): this;
573
574
  once(event: "close", listener: () => void): this;
574
575
  once(event: "connect", listener: () => void): this;
575
576
  once(event: "error", listener: (err: Error) => void): this;
576
577
  once(event: "listening", listener: () => void): this;
577
- once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
578
+ once(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
578
579
  prependListener(event: string, listener: (...args: any[]) => void): this;
579
580
  prependListener(event: "close", listener: () => void): this;
580
581
  prependListener(event: "connect", listener: () => void): this;
581
582
  prependListener(event: "error", listener: (err: Error) => void): this;
582
583
  prependListener(event: "listening", listener: () => void): this;
583
- prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
584
+ prependListener(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
584
585
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
585
586
  prependOnceListener(event: "close", listener: () => void): this;
586
587
  prependOnceListener(event: "connect", listener: () => void): this;
587
588
  prependOnceListener(event: "error", listener: (err: Error) => void): this;
588
589
  prependOnceListener(event: "listening", listener: () => void): this;
589
- prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
590
+ prependOnceListener(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
590
591
  /**
591
592
  * Calls `socket.close()` and returns a promise that fulfills when the socket has closed.
592
593
  * @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";
@@ -29,6 +30,8 @@ declare module "fs/promises" {
29
30
  OpenDirOptions,
30
31
  OpenMode,
31
32
  PathLike,
33
+ ReadOptions,
34
+ ReadOptionsWithBuffer,
32
35
  ReadPosition,
33
36
  ReadStream,
34
37
  ReadVResult,
@@ -57,6 +60,7 @@ declare module "fs/promises" {
57
60
  bytesRead: number;
58
61
  buffer: T;
59
62
  }
63
+ /** @deprecated This interface will be removed in a future version. Use `import { ReadOptionsWithBuffer } from "node:fs"` instead. */
60
64
  interface FileReadOptions<T extends NodeJS.ArrayBufferView = Buffer> {
61
65
  /**
62
66
  * @default `Buffer.alloc(0xffff)`
@@ -235,11 +239,13 @@ declare module "fs/promises" {
235
239
  length?: number | null,
236
240
  position?: ReadPosition | null,
237
241
  ): Promise<FileReadResult<T>>;
238
- read<T extends NodeJS.ArrayBufferView = Buffer>(
242
+ read<T extends NodeJS.ArrayBufferView>(
239
243
  buffer: T,
240
- options?: FileReadOptions<T>,
244
+ options?: ReadOptions,
245
+ ): Promise<FileReadResult<T>>;
246
+ read<T extends NodeJS.ArrayBufferView = NonSharedBuffer>(
247
+ options?: ReadOptionsWithBuffer<T>,
241
248
  ): Promise<FileReadResult<T>>;
242
- read<T extends NodeJS.ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
243
249
  /**
244
250
  * Returns a byte-oriented `ReadableStream` that may be used to read the file's
245
251
  * contents.
@@ -283,7 +289,7 @@ declare module "fs/promises" {
283
289
  options?:
284
290
  | ({ encoding?: null | undefined } & Abortable)
285
291
  | null,
286
- ): Promise<Buffer>;
292
+ ): Promise<NonSharedBuffer>;
287
293
  /**
288
294
  * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
289
295
  * The `FileHandle` must have been opened for reading.
@@ -302,7 +308,7 @@ declare module "fs/promises" {
302
308
  | (ObjectEncodingOptions & Abortable)
303
309
  | BufferEncoding
304
310
  | null,
305
- ): Promise<string | Buffer>;
311
+ ): Promise<string | NonSharedBuffer>;
306
312
  /**
307
313
  * Convenience method to create a `readline` interface and stream over the file.
308
314
  * See `filehandle.createReadStream()` for the options.
@@ -411,7 +417,7 @@ declare module "fs/promises" {
411
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
412
418
  * position. See the POSIX pwrite(2) documentation for more detail.
413
419
  */
414
- write<TBuffer extends Uint8Array>(
420
+ write<TBuffer extends NodeJS.ArrayBufferView>(
415
421
  buffer: TBuffer,
416
422
  offset?: number | null,
417
423
  length?: number | null,
@@ -450,14 +456,20 @@ declare module "fs/promises" {
450
456
  * @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
451
457
  * position.
452
458
  */
453
- writev(buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise<WriteVResult>;
459
+ writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
460
+ buffers: TBuffers,
461
+ position?: number,
462
+ ): Promise<WriteVResult<TBuffers>>;
454
463
  /**
455
464
  * Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s
456
465
  * @since v13.13.0, v12.17.0
457
466
  * @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.
458
467
  * @return Fulfills upon success an object containing two properties:
459
468
  */
460
- readv(buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise<ReadVResult>;
469
+ readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
470
+ buffers: TBuffers,
471
+ position?: number,
472
+ ): Promise<ReadVResult<TBuffers>>;
461
473
  /**
462
474
  * Closes the file handle after waiting for any pending operation on the handle to
463
475
  * complete.
@@ -694,7 +706,7 @@ declare module "fs/promises" {
694
706
  recursive?: boolean | undefined;
695
707
  }
696
708
  | "buffer",
697
- ): Promise<Buffer[]>;
709
+ ): Promise<NonSharedBuffer[]>;
698
710
  /**
699
711
  * Asynchronous readdir(3) - read a directory.
700
712
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -709,7 +721,7 @@ declare module "fs/promises" {
709
721
  })
710
722
  | BufferEncoding
711
723
  | null,
712
- ): Promise<string[] | Buffer[]>;
724
+ ): Promise<string[] | NonSharedBuffer[]>;
713
725
  /**
714
726
  * Asynchronous readdir(3) - read a directory.
715
727
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -734,7 +746,7 @@ declare module "fs/promises" {
734
746
  withFileTypes: true;
735
747
  recursive?: boolean | undefined;
736
748
  },
737
- ): Promise<Dirent<Buffer>[]>;
749
+ ): Promise<Dirent<NonSharedBuffer>[]>;
738
750
  /**
739
751
  * 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
740
752
  * fulfilled with the`linkString` upon success.
@@ -752,13 +764,16 @@ declare module "fs/promises" {
752
764
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
753
765
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
754
766
  */
755
- function readlink(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
767
+ function readlink(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
756
768
  /**
757
769
  * Asynchronous readlink(2) - read value of a symbolic link.
758
770
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
759
771
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
760
772
  */
761
- function readlink(path: PathLike, options?: ObjectEncodingOptions | string | null): Promise<string | Buffer>;
773
+ function readlink(
774
+ path: PathLike,
775
+ options?: ObjectEncodingOptions | string | null,
776
+ ): Promise<string | NonSharedBuffer>;
762
777
  /**
763
778
  * Creates a symbolic link.
764
779
  *
@@ -909,7 +924,7 @@ declare module "fs/promises" {
909
924
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
910
925
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
911
926
  */
912
- function realpath(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
927
+ function realpath(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
913
928
  /**
914
929
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
915
930
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -918,7 +933,7 @@ declare module "fs/promises" {
918
933
  function realpath(
919
934
  path: PathLike,
920
935
  options?: ObjectEncodingOptions | BufferEncoding | null,
921
- ): Promise<string | Buffer>;
936
+ ): Promise<string | NonSharedBuffer>;
922
937
  /**
923
938
  * Creates a unique temporary directory. A unique directory name is generated by
924
939
  * appending six random characters to the end of the provided `prefix`. Due to
@@ -954,13 +969,16 @@ declare module "fs/promises" {
954
969
  * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
955
970
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
956
971
  */
957
- function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<Buffer>;
972
+ function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<NonSharedBuffer>;
958
973
  /**
959
974
  * Asynchronously creates a unique temporary directory.
960
975
  * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
961
976
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
962
977
  */
963
- function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
978
+ function mkdtemp(
979
+ prefix: string,
980
+ options?: ObjectEncodingOptions | BufferEncoding | null,
981
+ ): Promise<string | NonSharedBuffer>;
964
982
  /**
965
983
  * Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an
966
984
  * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an
@@ -1116,7 +1134,7 @@ declare module "fs/promises" {
1116
1134
  flag?: OpenMode | undefined;
1117
1135
  } & Abortable)
1118
1136
  | null,
1119
- ): Promise<Buffer>;
1137
+ ): Promise<NonSharedBuffer>;
1120
1138
  /**
1121
1139
  * Asynchronously reads the entire contents of a file.
1122
1140
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -1152,7 +1170,7 @@ declare module "fs/promises" {
1152
1170
  )
1153
1171
  | BufferEncoding
1154
1172
  | null,
1155
- ): Promise<string | Buffer>;
1173
+ ): Promise<string | NonSharedBuffer>;
1156
1174
  /**
1157
1175
  * 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.
1158
1176
  *
@@ -1229,11 +1247,11 @@ declare module "fs/promises" {
1229
1247
  function watch(
1230
1248
  filename: PathLike,
1231
1249
  options: WatchOptionsWithBufferEncoding | "buffer",
1232
- ): NodeJS.AsyncIterator<FileChangeInfo<Buffer>>;
1250
+ ): NodeJS.AsyncIterator<FileChangeInfo<NonSharedBuffer>>;
1233
1251
  function watch(
1234
1252
  filename: PathLike,
1235
1253
  options: WatchOptions | BufferEncoding | "buffer",
1236
- ): NodeJS.AsyncIterator<FileChangeInfo<string | Buffer>>;
1254
+ ): NodeJS.AsyncIterator<FileChangeInfo<string | NonSharedBuffer>>;
1237
1255
  /**
1238
1256
  * Asynchronously copies the entire directory structure from `src` to `dest`,
1239
1257
  * including subdirectories and files.