@types/node 22.15.21 → 24.10.9
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 v24.10/README.md +15 -0
- node v24.10/assert/strict.d.ts +111 -0
- node/assert.d.ts → node v24.10/assert.d.ts +162 -101
- node/async_hooks.d.ts → node v24.10/async_hooks.d.ts +26 -6
- node/buffer.buffer.d.ts → node v24.10/buffer.buffer.d.ts +9 -0
- node/buffer.d.ts → node v24.10/buffer.d.ts +15 -7
- node/child_process.d.ts → node v24.10/child_process.d.ts +91 -164
- node/cluster.d.ts → node v24.10/cluster.d.ts +19 -20
- node/console.d.ts → node v24.10/console.d.ts +19 -18
- node/crypto.d.ts → node v24.10/crypto.d.ts +1264 -356
- node/dgram.d.ts → node v24.10/dgram.d.ts +10 -9
- node/diagnostics_channel.d.ts → node v24.10/diagnostics_channel.d.ts +18 -15
- node/dns/promises.d.ts → node v24.10/dns/promises.d.ts +36 -9
- node/dns.d.ts → node v24.10/dns.d.ts +95 -37
- node/domain.d.ts → node v24.10/domain.d.ts +1 -1
- node/events.d.ts → node v24.10/events.d.ts +81 -36
- node/fs/promises.d.ts → node v24.10/fs/promises.d.ts +117 -59
- node/fs.d.ts → node v24.10/fs.d.ts +414 -137
- node v24.10/globals.d.ts +170 -0
- node v24.10/globals.typedarray.d.ts +41 -0
- node/http.d.ts → node v24.10/http.d.ts +187 -37
- node/http2.d.ts → node v24.10/http2.d.ts +266 -67
- node/https.d.ts → node v24.10/https.d.ts +97 -63
- node/index.d.ts → node v24.10/index.d.ts +16 -7
- node v24.10/inspector.d.ts +277 -0
- node/inspector.d.ts → node v24.10/inspector.generated.d.ts +1059 -828
- node/module.d.ts → node v24.10/module.d.ts +153 -31
- node/net.d.ts → node v24.10/net.d.ts +35 -16
- node/os.d.ts → node v24.10/os.d.ts +22 -10
- node/package.json → node v24.10/package.json +14 -84
- node/path.d.ts → node v24.10/path.d.ts +2 -2
- node/perf_hooks.d.ts → node v24.10/perf_hooks.d.ts +30 -18
- node/process.d.ts → node v24.10/process.d.ts +59 -34
- node/punycode.d.ts → node v24.10/punycode.d.ts +1 -1
- node/querystring.d.ts → node v24.10/querystring.d.ts +1 -1
- node/readline/promises.d.ts → node v24.10/readline/promises.d.ts +1 -2
- node/readline.d.ts → node v24.10/readline.d.ts +13 -13
- node/repl.d.ts → node v24.10/repl.d.ts +25 -17
- node/sea.d.ts → node v24.10/sea.d.ts +10 -1
- node/sqlite.d.ts → node v24.10/sqlite.d.ts +438 -9
- node/stream/consumers.d.ts → node v24.10/stream/consumers.d.ts +2 -2
- node/stream/web.d.ts → node v24.10/stream/web.d.ts +13 -54
- node/stream.d.ts → node v24.10/stream.d.ts +68 -47
- node/string_decoder.d.ts → node v24.10/string_decoder.d.ts +3 -3
- node v24.10/test.d.ts +2339 -0
- node/timers/promises.d.ts → node v24.10/timers/promises.d.ts +1 -1
- node/timers.d.ts → node v24.10/timers.d.ts +1 -3
- node/tls.d.ts → node v24.10/tls.d.ts +128 -114
- node/trace_events.d.ts → node v24.10/trace_events.d.ts +6 -6
- node/ts5.6/buffer.buffer.d.ts → node v24.10/ts5.6/buffer.buffer.d.ts +10 -2
- node v24.10/ts5.6/compatibility/float16array.d.ts +71 -0
- node v24.10/ts5.6/globals.typedarray.d.ts +36 -0
- node/ts5.6/index.d.ts → node v24.10/ts5.6/index.d.ts +18 -7
- node v24.10/ts5.7/compatibility/float16array.d.ts +72 -0
- node v24.10/ts5.7/index.d.ts +103 -0
- node/tty.d.ts → node v24.10/tty.d.ts +1 -1
- node/url.d.ts → node v24.10/url.d.ts +119 -34
- node/util.d.ts → node v24.10/util.d.ts +46 -305
- node/v8.d.ts → node v24.10/v8.d.ts +100 -37
- node/vm.d.ts → node v24.10/vm.d.ts +299 -110
- node/wasi.d.ts → node v24.10/wasi.d.ts +23 -2
- node v24.10/web-globals/abortcontroller.d.ts +34 -0
- node v24.10/web-globals/crypto.d.ts +32 -0
- node v24.10/web-globals/domexception.d.ts +68 -0
- node v24.10/web-globals/events.d.ts +97 -0
- node v24.10/web-globals/fetch.d.ts +50 -0
- node v24.10/web-globals/navigator.d.ts +25 -0
- node v24.10/web-globals/storage.d.ts +24 -0
- node v24.10/web-globals/streams.d.ts +22 -0
- node/worker_threads.d.ts → node v24.10/worker_threads.d.ts +225 -75
- node/zlib.d.ts → node v24.10/zlib.d.ts +44 -33
- node/README.md +0 -15
- node/assert/strict.d.ts +0 -8
- node/compatibility/disposable.d.ts +0 -16
- node/compatibility/index.d.ts +0 -9
- node/compatibility/indexable.d.ts +0 -23
- node/dom-events.d.ts +0 -124
- node/globals.d.ts +0 -371
- node/globals.typedarray.d.ts +0 -21
- node/test.d.ts +0 -2280
- node/ts5.6/globals.typedarray.d.ts +0 -19
- {node → node v24.10}/LICENSE +0 -0
- {node → node v24.10}/compatibility/iterators.d.ts +0 -0
- {node → node v24.10}/constants.d.ts +0 -0
- {node → node v24.10}/stream/promises.d.ts +0 -0
|
@@ -32,43 +32,10 @@
|
|
|
32
32
|
* });
|
|
33
33
|
* myEmitter.emit('event');
|
|
34
34
|
* ```
|
|
35
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
35
|
+
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/events.js)
|
|
36
36
|
*/
|
|
37
37
|
declare module "events" {
|
|
38
38
|
import { AsyncResource, AsyncResourceOptions } from "node:async_hooks";
|
|
39
|
-
// NOTE: This class is in the docs but is **not actually exported** by Node.
|
|
40
|
-
// If https://github.com/nodejs/node/issues/39903 gets resolved and Node
|
|
41
|
-
// actually starts exporting the class, uncomment below.
|
|
42
|
-
// import { EventListener, EventListenerObject } from '__dom-events';
|
|
43
|
-
// /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */
|
|
44
|
-
// interface NodeEventTarget extends EventTarget {
|
|
45
|
-
// /**
|
|
46
|
-
// * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API.
|
|
47
|
-
// * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget.
|
|
48
|
-
// */
|
|
49
|
-
// addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
|
|
50
|
-
// /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */
|
|
51
|
-
// eventNames(): string[];
|
|
52
|
-
// /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */
|
|
53
|
-
// listenerCount(type: string): number;
|
|
54
|
-
// /** Node.js-specific alias for `eventTarget.removeListener()`. */
|
|
55
|
-
// off(type: string, listener: EventListener | EventListenerObject): this;
|
|
56
|
-
// /** Node.js-specific alias for `eventTarget.addListener()`. */
|
|
57
|
-
// on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
|
|
58
|
-
// /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */
|
|
59
|
-
// once(type: string, listener: EventListener | EventListenerObject): this;
|
|
60
|
-
// /**
|
|
61
|
-
// * Node.js-specific extension to the `EventTarget` class.
|
|
62
|
-
// * If `type` is specified, removes all registered listeners for `type`,
|
|
63
|
-
// * otherwise removes all registered listeners.
|
|
64
|
-
// */
|
|
65
|
-
// removeAllListeners(type: string): this;
|
|
66
|
-
// /**
|
|
67
|
-
// * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`.
|
|
68
|
-
// * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`.
|
|
69
|
-
// */
|
|
70
|
-
// removeListener(type: string, listener: EventListener | EventListenerObject): this;
|
|
71
|
-
// }
|
|
72
39
|
interface EventEmitterOptions {
|
|
73
40
|
/**
|
|
74
41
|
* Enables automatic capturing of promise rejection.
|
|
@@ -431,7 +398,6 @@ declare module "events" {
|
|
|
431
398
|
* }
|
|
432
399
|
* ```
|
|
433
400
|
* @since v20.5.0
|
|
434
|
-
* @experimental
|
|
435
401
|
* @return Disposable that removes the `abort` listener.
|
|
436
402
|
*/
|
|
437
403
|
static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable;
|
|
@@ -518,7 +484,7 @@ declare module "events" {
|
|
|
518
484
|
* directly rather than as a child class.
|
|
519
485
|
* @default new.target.name if instantiated as a child class.
|
|
520
486
|
*/
|
|
521
|
-
name?: string;
|
|
487
|
+
name?: string | undefined;
|
|
522
488
|
}
|
|
523
489
|
|
|
524
490
|
/**
|
|
@@ -585,6 +551,85 @@ declare module "events" {
|
|
|
585
551
|
*/
|
|
586
552
|
readonly asyncResource: EventEmitterReferencingAsyncResource;
|
|
587
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* The `NodeEventTarget` is a Node.js-specific extension to `EventTarget`
|
|
556
|
+
* that emulates a subset of the `EventEmitter` API.
|
|
557
|
+
* @since v14.5.0
|
|
558
|
+
*/
|
|
559
|
+
export interface NodeEventTarget extends EventTarget {
|
|
560
|
+
/**
|
|
561
|
+
* Node.js-specific extension to the `EventTarget` class that emulates the
|
|
562
|
+
* equivalent `EventEmitter` API. The only difference between `addListener()` and
|
|
563
|
+
* `addEventListener()` is that `addListener()` will return a reference to the
|
|
564
|
+
* `EventTarget`.
|
|
565
|
+
* @since v14.5.0
|
|
566
|
+
*/
|
|
567
|
+
addListener(type: string, listener: (arg: any) => void): this;
|
|
568
|
+
/**
|
|
569
|
+
* Node.js-specific extension to the `EventTarget` class that dispatches the
|
|
570
|
+
* `arg` to the list of handlers for `type`.
|
|
571
|
+
* @since v15.2.0
|
|
572
|
+
* @returns `true` if event listeners registered for the `type` exist,
|
|
573
|
+
* otherwise `false`.
|
|
574
|
+
*/
|
|
575
|
+
emit(type: string, arg: any): boolean;
|
|
576
|
+
/**
|
|
577
|
+
* Node.js-specific extension to the `EventTarget` class that returns an array
|
|
578
|
+
* of event `type` names for which event listeners are registered.
|
|
579
|
+
* @since 14.5.0
|
|
580
|
+
*/
|
|
581
|
+
eventNames(): string[];
|
|
582
|
+
/**
|
|
583
|
+
* Node.js-specific extension to the `EventTarget` class that returns the number
|
|
584
|
+
* of event listeners registered for the `type`.
|
|
585
|
+
* @since v14.5.0
|
|
586
|
+
*/
|
|
587
|
+
listenerCount(type: string): number;
|
|
588
|
+
/**
|
|
589
|
+
* Node.js-specific extension to the `EventTarget` class that sets the number
|
|
590
|
+
* of max event listeners as `n`.
|
|
591
|
+
* @since v14.5.0
|
|
592
|
+
*/
|
|
593
|
+
setMaxListeners(n: number): void;
|
|
594
|
+
/**
|
|
595
|
+
* Node.js-specific extension to the `EventTarget` class that returns the number
|
|
596
|
+
* of max event listeners.
|
|
597
|
+
* @since v14.5.0
|
|
598
|
+
*/
|
|
599
|
+
getMaxListeners(): number;
|
|
600
|
+
/**
|
|
601
|
+
* Node.js-specific alias for `eventTarget.removeEventListener()`.
|
|
602
|
+
* @since v14.5.0
|
|
603
|
+
*/
|
|
604
|
+
off(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
|
|
605
|
+
/**
|
|
606
|
+
* Node.js-specific alias for `eventTarget.addEventListener()`.
|
|
607
|
+
* @since v14.5.0
|
|
608
|
+
*/
|
|
609
|
+
on(type: string, listener: (arg: any) => void): this;
|
|
610
|
+
/**
|
|
611
|
+
* Node.js-specific extension to the `EventTarget` class that adds a `once`
|
|
612
|
+
* listener for the given event `type`. This is equivalent to calling `on`
|
|
613
|
+
* with the `once` option set to `true`.
|
|
614
|
+
* @since v14.5.0
|
|
615
|
+
*/
|
|
616
|
+
once(type: string, listener: (arg: any) => void): this;
|
|
617
|
+
/**
|
|
618
|
+
* Node.js-specific extension to the `EventTarget` class. If `type` is specified,
|
|
619
|
+
* removes all registered listeners for `type`, otherwise removes all registered
|
|
620
|
+
* listeners.
|
|
621
|
+
* @since v14.5.0
|
|
622
|
+
*/
|
|
623
|
+
removeAllListeners(type?: string): this;
|
|
624
|
+
/**
|
|
625
|
+
* Node.js-specific extension to the `EventTarget` class that removes the
|
|
626
|
+
* `listener` for the given `type`. The only difference between `removeListener()`
|
|
627
|
+
* and `removeEventListener()` is that `removeListener()` will return a reference
|
|
628
|
+
* to the `EventTarget`.
|
|
629
|
+
* @since v14.5.0
|
|
630
|
+
*/
|
|
631
|
+
removeListener(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
|
|
632
|
+
}
|
|
588
633
|
}
|
|
589
634
|
global {
|
|
590
635
|
namespace NodeJS {
|
|
@@ -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";
|
|
@@ -20,6 +21,7 @@ declare module "fs/promises" {
|
|
|
20
21
|
CopyOptions,
|
|
21
22
|
Dir,
|
|
22
23
|
Dirent,
|
|
24
|
+
EncodingOption,
|
|
23
25
|
GlobOptions,
|
|
24
26
|
GlobOptionsWithFileTypes,
|
|
25
27
|
GlobOptionsWithoutFileTypes,
|
|
@@ -29,6 +31,9 @@ declare module "fs/promises" {
|
|
|
29
31
|
OpenDirOptions,
|
|
30
32
|
OpenMode,
|
|
31
33
|
PathLike,
|
|
34
|
+
ReadOptions,
|
|
35
|
+
ReadOptionsWithBuffer,
|
|
36
|
+
ReadPosition,
|
|
32
37
|
ReadStream,
|
|
33
38
|
ReadVResult,
|
|
34
39
|
RmDirOptions,
|
|
@@ -39,7 +44,7 @@ declare module "fs/promises" {
|
|
|
39
44
|
StatsFs,
|
|
40
45
|
TimeLike,
|
|
41
46
|
WatchEventType,
|
|
42
|
-
WatchOptions,
|
|
47
|
+
WatchOptions as _WatchOptions,
|
|
43
48
|
WriteStream,
|
|
44
49
|
WriteVResult,
|
|
45
50
|
} from "node:fs";
|
|
@@ -56,6 +61,7 @@ declare module "fs/promises" {
|
|
|
56
61
|
bytesRead: number;
|
|
57
62
|
buffer: T;
|
|
58
63
|
}
|
|
64
|
+
/** @deprecated This interface will be removed in a future version. Use `import { ReadOptionsWithBuffer } from "node:fs"` instead. */
|
|
59
65
|
interface FileReadOptions<T extends NodeJS.ArrayBufferView = Buffer> {
|
|
60
66
|
/**
|
|
61
67
|
* @default `Buffer.alloc(0xffff)`
|
|
@@ -69,7 +75,7 @@ declare module "fs/promises" {
|
|
|
69
75
|
* @default `buffer.byteLength`
|
|
70
76
|
*/
|
|
71
77
|
length?: number | null;
|
|
72
|
-
position?:
|
|
78
|
+
position?: ReadPosition | null;
|
|
73
79
|
}
|
|
74
80
|
interface CreateReadStreamOptions extends Abortable {
|
|
75
81
|
encoding?: BufferEncoding | null | undefined;
|
|
@@ -87,6 +93,9 @@ declare module "fs/promises" {
|
|
|
87
93
|
highWaterMark?: number | undefined;
|
|
88
94
|
flush?: boolean | undefined;
|
|
89
95
|
}
|
|
96
|
+
interface ReadableWebStreamOptions {
|
|
97
|
+
autoClose?: boolean | undefined;
|
|
98
|
+
}
|
|
90
99
|
// TODO: Add `EventEmitter` close
|
|
91
100
|
interface FileHandle {
|
|
92
101
|
/**
|
|
@@ -229,13 +238,15 @@ declare module "fs/promises" {
|
|
|
229
238
|
buffer: T,
|
|
230
239
|
offset?: number | null,
|
|
231
240
|
length?: number | null,
|
|
232
|
-
position?:
|
|
241
|
+
position?: ReadPosition | null,
|
|
233
242
|
): Promise<FileReadResult<T>>;
|
|
234
|
-
read<T extends NodeJS.ArrayBufferView
|
|
243
|
+
read<T extends NodeJS.ArrayBufferView>(
|
|
235
244
|
buffer: T,
|
|
236
|
-
options?:
|
|
245
|
+
options?: ReadOptions,
|
|
246
|
+
): Promise<FileReadResult<T>>;
|
|
247
|
+
read<T extends NodeJS.ArrayBufferView = NonSharedBuffer>(
|
|
248
|
+
options?: ReadOptionsWithBuffer<T>,
|
|
237
249
|
): Promise<FileReadResult<T>>;
|
|
238
|
-
read<T extends NodeJS.ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
|
|
239
250
|
/**
|
|
240
251
|
* Returns a byte-oriented `ReadableStream` that may be used to read the file's
|
|
241
252
|
* contents.
|
|
@@ -259,9 +270,8 @@ declare module "fs/promises" {
|
|
|
259
270
|
* While the `ReadableStream` will read the file to completion, it will not
|
|
260
271
|
* close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method.
|
|
261
272
|
* @since v17.0.0
|
|
262
|
-
* @experimental
|
|
263
273
|
*/
|
|
264
|
-
readableWebStream(): ReadableStream;
|
|
274
|
+
readableWebStream(options?: ReadableWebStreamOptions): ReadableStream;
|
|
265
275
|
/**
|
|
266
276
|
* Asynchronously reads the entire contents of a file.
|
|
267
277
|
*
|
|
@@ -280,7 +290,7 @@ declare module "fs/promises" {
|
|
|
280
290
|
options?:
|
|
281
291
|
| ({ encoding?: null | undefined } & Abortable)
|
|
282
292
|
| null,
|
|
283
|
-
): Promise<
|
|
293
|
+
): Promise<NonSharedBuffer>;
|
|
284
294
|
/**
|
|
285
295
|
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
|
286
296
|
* The `FileHandle` must have been opened for reading.
|
|
@@ -299,7 +309,7 @@ declare module "fs/promises" {
|
|
|
299
309
|
| (ObjectEncodingOptions & Abortable)
|
|
300
310
|
| BufferEncoding
|
|
301
311
|
| null,
|
|
302
|
-
): Promise<string |
|
|
312
|
+
): Promise<string | NonSharedBuffer>;
|
|
303
313
|
/**
|
|
304
314
|
* Convenience method to create a `readline` interface and stream over the file.
|
|
305
315
|
* See `filehandle.createReadStream()` for the options.
|
|
@@ -408,7 +418,7 @@ declare module "fs/promises" {
|
|
|
408
418
|
* @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
|
|
409
419
|
* position. See the POSIX pwrite(2) documentation for more detail.
|
|
410
420
|
*/
|
|
411
|
-
write<TBuffer extends
|
|
421
|
+
write<TBuffer extends NodeJS.ArrayBufferView>(
|
|
412
422
|
buffer: TBuffer,
|
|
413
423
|
offset?: number | null,
|
|
414
424
|
length?: number | null,
|
|
@@ -447,14 +457,20 @@ declare module "fs/promises" {
|
|
|
447
457
|
* @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
|
|
448
458
|
* position.
|
|
449
459
|
*/
|
|
450
|
-
writev
|
|
460
|
+
writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
|
|
461
|
+
buffers: TBuffers,
|
|
462
|
+
position?: number,
|
|
463
|
+
): Promise<WriteVResult<TBuffers>>;
|
|
451
464
|
/**
|
|
452
465
|
* Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s
|
|
453
466
|
* @since v13.13.0, v12.17.0
|
|
454
467
|
* @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.
|
|
455
468
|
* @return Fulfills upon success an object containing two properties:
|
|
456
469
|
*/
|
|
457
|
-
readv
|
|
470
|
+
readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
|
|
471
|
+
buffers: TBuffers,
|
|
472
|
+
position?: number,
|
|
473
|
+
): Promise<ReadVResult<TBuffers>>;
|
|
458
474
|
/**
|
|
459
475
|
* Closes the file handle after waiting for any pending operation on the handle to
|
|
460
476
|
* complete.
|
|
@@ -474,8 +490,9 @@ declare module "fs/promises" {
|
|
|
474
490
|
*/
|
|
475
491
|
close(): Promise<void>;
|
|
476
492
|
/**
|
|
477
|
-
*
|
|
478
|
-
*
|
|
493
|
+
* Calls `filehandle.close()` and returns a promise that fulfills when the
|
|
494
|
+
* filehandle is closed.
|
|
495
|
+
* @since v20.4.0, v18.8.0
|
|
479
496
|
*/
|
|
480
497
|
[Symbol.asyncDispose](): Promise<void>;
|
|
481
498
|
}
|
|
@@ -690,7 +707,7 @@ declare module "fs/promises" {
|
|
|
690
707
|
recursive?: boolean | undefined;
|
|
691
708
|
}
|
|
692
709
|
| "buffer",
|
|
693
|
-
): Promise<
|
|
710
|
+
): Promise<NonSharedBuffer[]>;
|
|
694
711
|
/**
|
|
695
712
|
* Asynchronous readdir(3) - read a directory.
|
|
696
713
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -705,7 +722,7 @@ declare module "fs/promises" {
|
|
|
705
722
|
})
|
|
706
723
|
| BufferEncoding
|
|
707
724
|
| null,
|
|
708
|
-
): Promise<string[] |
|
|
725
|
+
): Promise<string[] | NonSharedBuffer[]>;
|
|
709
726
|
/**
|
|
710
727
|
* Asynchronous readdir(3) - read a directory.
|
|
711
728
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -730,7 +747,7 @@ declare module "fs/promises" {
|
|
|
730
747
|
withFileTypes: true;
|
|
731
748
|
recursive?: boolean | undefined;
|
|
732
749
|
},
|
|
733
|
-
): Promise<Dirent<
|
|
750
|
+
): Promise<Dirent<NonSharedBuffer>[]>;
|
|
734
751
|
/**
|
|
735
752
|
* 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
|
|
736
753
|
* fulfilled with the`linkString` upon success.
|
|
@@ -748,13 +765,16 @@ declare module "fs/promises" {
|
|
|
748
765
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
749
766
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
750
767
|
*/
|
|
751
|
-
function readlink(path: PathLike, options: BufferEncodingOption): Promise<
|
|
768
|
+
function readlink(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
|
|
752
769
|
/**
|
|
753
770
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
754
771
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
755
772
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
756
773
|
*/
|
|
757
|
-
function readlink(
|
|
774
|
+
function readlink(
|
|
775
|
+
path: PathLike,
|
|
776
|
+
options?: ObjectEncodingOptions | string | null,
|
|
777
|
+
): Promise<string | NonSharedBuffer>;
|
|
758
778
|
/**
|
|
759
779
|
* Creates a symbolic link.
|
|
760
780
|
*
|
|
@@ -905,7 +925,7 @@ declare module "fs/promises" {
|
|
|
905
925
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
906
926
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
907
927
|
*/
|
|
908
|
-
function realpath(path: PathLike, options: BufferEncodingOption): Promise<
|
|
928
|
+
function realpath(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
|
|
909
929
|
/**
|
|
910
930
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
911
931
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -914,7 +934,7 @@ declare module "fs/promises" {
|
|
|
914
934
|
function realpath(
|
|
915
935
|
path: PathLike,
|
|
916
936
|
options?: ObjectEncodingOptions | BufferEncoding | null,
|
|
917
|
-
): Promise<string |
|
|
937
|
+
): Promise<string | NonSharedBuffer>;
|
|
918
938
|
/**
|
|
919
939
|
* Creates a unique temporary directory. A unique directory name is generated by
|
|
920
940
|
* appending six random characters to the end of the provided `prefix`. Due to
|
|
@@ -950,13 +970,50 @@ declare module "fs/promises" {
|
|
|
950
970
|
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
|
951
971
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
952
972
|
*/
|
|
953
|
-
function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<
|
|
973
|
+
function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<NonSharedBuffer>;
|
|
954
974
|
/**
|
|
955
975
|
* Asynchronously creates a unique temporary directory.
|
|
956
976
|
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
|
957
977
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
958
978
|
*/
|
|
959
|
-
function mkdtemp(
|
|
979
|
+
function mkdtemp(
|
|
980
|
+
prefix: string,
|
|
981
|
+
options?: ObjectEncodingOptions | BufferEncoding | null,
|
|
982
|
+
): Promise<string | NonSharedBuffer>;
|
|
983
|
+
interface DisposableTempDir extends AsyncDisposable {
|
|
984
|
+
/**
|
|
985
|
+
* The path of the created directory.
|
|
986
|
+
*/
|
|
987
|
+
path: string;
|
|
988
|
+
/**
|
|
989
|
+
* A function which removes the created directory.
|
|
990
|
+
*/
|
|
991
|
+
remove(): Promise<void>;
|
|
992
|
+
/**
|
|
993
|
+
* The same as `remove`.
|
|
994
|
+
*/
|
|
995
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* The resulting Promise holds an async-disposable object whose `path` property
|
|
999
|
+
* holds the created directory path. When the object is disposed, the directory
|
|
1000
|
+
* and its contents will be removed asynchronously if it still exists. If the
|
|
1001
|
+
* directory cannot be deleted, disposal will throw an error. The object has an
|
|
1002
|
+
* async `remove()` method which will perform the same task.
|
|
1003
|
+
*
|
|
1004
|
+
* Both this function and the disposal function on the resulting object are
|
|
1005
|
+
* async, so it should be used with `await` + `await using` as in
|
|
1006
|
+
* `await using dir = await fsPromises.mkdtempDisposable('prefix')`.
|
|
1007
|
+
*
|
|
1008
|
+
* <!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
|
|
1009
|
+
*
|
|
1010
|
+
* For detailed information, see the documentation of `fsPromises.mkdtemp()`.
|
|
1011
|
+
*
|
|
1012
|
+
* The optional `options` argument can be a string specifying an encoding, or an
|
|
1013
|
+
* object with an `encoding` property specifying the character encoding to use.
|
|
1014
|
+
* @since v24.4.0
|
|
1015
|
+
*/
|
|
1016
|
+
function mkdtempDisposable(prefix: PathLike, options?: EncodingOption): Promise<DisposableTempDir>;
|
|
960
1017
|
/**
|
|
961
1018
|
* Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an
|
|
962
1019
|
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an
|
|
@@ -1112,7 +1169,7 @@ declare module "fs/promises" {
|
|
|
1112
1169
|
flag?: OpenMode | undefined;
|
|
1113
1170
|
} & Abortable)
|
|
1114
1171
|
| null,
|
|
1115
|
-
): Promise<
|
|
1172
|
+
): Promise<NonSharedBuffer>;
|
|
1116
1173
|
/**
|
|
1117
1174
|
* Asynchronously reads the entire contents of a file.
|
|
1118
1175
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1148,7 +1205,7 @@ declare module "fs/promises" {
|
|
|
1148
1205
|
)
|
|
1149
1206
|
| BufferEncoding
|
|
1150
1207
|
| null,
|
|
1151
|
-
): Promise<string |
|
|
1208
|
+
): Promise<string | NonSharedBuffer>;
|
|
1152
1209
|
/**
|
|
1153
1210
|
* 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.
|
|
1154
1211
|
*
|
|
@@ -1178,6 +1235,16 @@ declare module "fs/promises" {
|
|
|
1178
1235
|
* @return Fulfills with an {fs.Dir}.
|
|
1179
1236
|
*/
|
|
1180
1237
|
function opendir(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
|
|
1238
|
+
interface WatchOptions extends _WatchOptions {
|
|
1239
|
+
maxQueue?: number | undefined;
|
|
1240
|
+
overflow?: "ignore" | "throw" | undefined;
|
|
1241
|
+
}
|
|
1242
|
+
interface WatchOptionsWithBufferEncoding extends WatchOptions {
|
|
1243
|
+
encoding: "buffer";
|
|
1244
|
+
}
|
|
1245
|
+
interface WatchOptionsWithStringEncoding extends WatchOptions {
|
|
1246
|
+
encoding?: BufferEncoding | undefined;
|
|
1247
|
+
}
|
|
1181
1248
|
/**
|
|
1182
1249
|
* Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
|
|
1183
1250
|
*
|
|
@@ -1210,33 +1277,16 @@ declare module "fs/promises" {
|
|
|
1210
1277
|
*/
|
|
1211
1278
|
function watch(
|
|
1212
1279
|
filename: PathLike,
|
|
1213
|
-
options
|
|
1214
|
-
|
|
1215
|
-
encoding: "buffer";
|
|
1216
|
-
})
|
|
1217
|
-
| "buffer",
|
|
1218
|
-
): AsyncIterable<FileChangeInfo<Buffer>>;
|
|
1219
|
-
/**
|
|
1220
|
-
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
|
1221
|
-
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
|
1222
|
-
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
|
|
1223
|
-
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
|
1224
|
-
* If `persistent` is not supplied, the default of `true` is used.
|
|
1225
|
-
* If `recursive` is not supplied, the default of `false` is used.
|
|
1226
|
-
*/
|
|
1227
|
-
function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable<FileChangeInfo<string>>;
|
|
1228
|
-
/**
|
|
1229
|
-
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
|
1230
|
-
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
|
1231
|
-
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
|
|
1232
|
-
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
|
1233
|
-
* If `persistent` is not supplied, the default of `true` is used.
|
|
1234
|
-
* If `recursive` is not supplied, the default of `false` is used.
|
|
1235
|
-
*/
|
|
1280
|
+
options?: WatchOptionsWithStringEncoding | BufferEncoding,
|
|
1281
|
+
): NodeJS.AsyncIterator<FileChangeInfo<string>>;
|
|
1236
1282
|
function watch(
|
|
1237
1283
|
filename: PathLike,
|
|
1238
|
-
options:
|
|
1239
|
-
):
|
|
1284
|
+
options: WatchOptionsWithBufferEncoding | "buffer",
|
|
1285
|
+
): NodeJS.AsyncIterator<FileChangeInfo<NonSharedBuffer>>;
|
|
1286
|
+
function watch(
|
|
1287
|
+
filename: PathLike,
|
|
1288
|
+
options: WatchOptions | BufferEncoding | "buffer",
|
|
1289
|
+
): NodeJS.AsyncIterator<FileChangeInfo<string | NonSharedBuffer>>;
|
|
1240
1290
|
/**
|
|
1241
1291
|
* Asynchronously copies the entire directory structure from `src` to `dest`,
|
|
1242
1292
|
* including subdirectories and files.
|
|
@@ -1251,20 +1301,28 @@ declare module "fs/promises" {
|
|
|
1251
1301
|
*/
|
|
1252
1302
|
function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
|
|
1253
1303
|
/**
|
|
1254
|
-
*
|
|
1304
|
+
* ```js
|
|
1305
|
+
* import { glob } from 'node:fs/promises';
|
|
1306
|
+
*
|
|
1307
|
+
* for await (const entry of glob('*.js'))
|
|
1308
|
+
* console.log(entry);
|
|
1309
|
+
* ```
|
|
1310
|
+
* @since v22.0.0
|
|
1311
|
+
* @returns An AsyncIterator that yields the paths of files
|
|
1312
|
+
* that match the pattern.
|
|
1255
1313
|
*/
|
|
1256
|
-
function glob(pattern: string | string[]): NodeJS.AsyncIterator<string>;
|
|
1314
|
+
function glob(pattern: string | readonly string[]): NodeJS.AsyncIterator<string>;
|
|
1257
1315
|
function glob(
|
|
1258
|
-
pattern: string | string[],
|
|
1259
|
-
|
|
1316
|
+
pattern: string | readonly string[],
|
|
1317
|
+
options: GlobOptionsWithFileTypes,
|
|
1260
1318
|
): NodeJS.AsyncIterator<Dirent>;
|
|
1261
1319
|
function glob(
|
|
1262
|
-
pattern: string | string[],
|
|
1263
|
-
|
|
1320
|
+
pattern: string | readonly string[],
|
|
1321
|
+
options: GlobOptionsWithoutFileTypes,
|
|
1264
1322
|
): NodeJS.AsyncIterator<string>;
|
|
1265
1323
|
function glob(
|
|
1266
|
-
pattern: string | string[],
|
|
1267
|
-
|
|
1324
|
+
pattern: string | readonly string[],
|
|
1325
|
+
options: GlobOptions,
|
|
1268
1326
|
): NodeJS.AsyncIterator<Dirent | string>;
|
|
1269
1327
|
}
|
|
1270
1328
|
declare module "node:fs/promises" {
|