@types/node 22.15.33 → 22.18.13
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/README.md +15 -0
- {node v22.15 → node v22.18}/assert.d.ts +19 -0
- {node v22.15 → node v22.18}/buffer.buffer.d.ts +9 -0
- {node v22.15 → node v22.18}/buffer.d.ts +14 -6
- {node v22.15 → node v22.18}/child_process.d.ts +89 -162
- {node v22.15 → node v22.18}/cluster.d.ts +4 -5
- {node v22.15 → node v22.18}/crypto.d.ts +203 -167
- {node v22.15 → node v22.18}/dgram.d.ts +9 -8
- {node v22.15 → node v22.18}/dns/promises.d.ts +11 -10
- {node v22.15 → node v22.18}/dns.d.ts +19 -20
- {node v22.15 → node v22.18}/events.d.ts +80 -35
- {node v22.15 → node v22.18}/fs/promises.d.ts +78 -56
- {node v22.15 → node v22.18}/fs.d.ts +153 -129
- node v22.18/globals.d.ts +172 -0
- node v22.18/globals.typedarray.d.ts +38 -0
- {node v22.15 → node v22.18}/http.d.ts +112 -32
- {node v22.15 → node v22.18}/http2.d.ts +45 -26
- {node v22.15 → node v22.18}/https.d.ts +96 -62
- {node v22.15 → node v22.18}/index.d.ts +7 -3
- node v22.15/inspector.d.ts → node v22.18/inspector.generated.d.ts +219 -10
- {node v22.15 → node v22.18}/module.d.ts +70 -13
- {node v22.15 → node v22.18}/net.d.ts +12 -11
- {node v22.15 → node v22.18}/os.d.ts +14 -3
- {node v22.15 → node v22.18}/package.json +3 -83
- {node v22.15 → node v22.18}/perf_hooks.d.ts +6 -8
- {node v22.15 → node v22.18}/process.d.ts +15 -27
- {node v22.15 → node v22.18}/readline/promises.d.ts +1 -2
- {node v22.15 → node v22.18}/repl.d.ts +3 -5
- {node v22.15 → node v22.18}/sqlite.d.ts +212 -6
- {node v22.15 → node v22.18}/stream/consumers.d.ts +2 -2
- {node v22.15 → node v22.18}/stream/web.d.ts +8 -0
- {node v22.15 → node v22.18}/stream.d.ts +29 -33
- {node v22.15 → node v22.18}/string_decoder.d.ts +2 -2
- node v22.18/test.d.ts +2162 -0
- {node v22.15 → node v22.18}/tls.d.ts +90 -66
- {node v22.15 → node v22.18}/ts5.6/buffer.buffer.d.ts +10 -2
- node v22.18/ts5.6/globals.typedarray.d.ts +34 -0
- {node v22.15 → node v22.18}/ts5.6/index.d.ts +7 -3
- {node v22.15 → node v22.18}/url.d.ts +13 -4
- {node v22.15 → node v22.18}/util.d.ts +21 -6
- {node v22.15 → node v22.18}/v8.d.ts +33 -35
- {node v22.15 → node v22.18}/vm.d.ts +21 -50
- {node v22.15 → node v22.18}/wasi.d.ts +1 -1
- node v22.18/web-globals/abortcontroller.d.ts +34 -0
- node v22.18/web-globals/domexception.d.ts +68 -0
- node v22.15/dom-events.d.ts → node v22.18/web-globals/events.d.ts +49 -51
- node v22.18/web-globals/fetch.d.ts +46 -0
- node v22.18/web-globals/navigator.d.ts +22 -0
- node v22.18/web-globals/storage.d.ts +24 -0
- {node v22.15 → node v22.18}/worker_threads.d.ts +86 -67
- {node v22.15 → node v22.18}/zlib.d.ts +33 -26
- node v22.15/README.md +0 -15
- node v22.15/globals.d.ts +0 -364
- node v22.15/globals.typedarray.d.ts +0 -21
- node v22.15/test.d.ts +0 -2278
- node v22.15/ts5.6/globals.typedarray.d.ts +0 -19
- {node v22.15 → node v22.18}/LICENSE +0 -0
- {node v22.15 → node v22.18}/assert/strict.d.ts +0 -0
- {node v22.15 → node v22.18}/async_hooks.d.ts +1 -1
- {node v22.15 → node v22.18}/compatibility/disposable.d.ts +0 -0
- {node v22.15 → node v22.18}/compatibility/index.d.ts +0 -0
- {node v22.15 → node v22.18}/compatibility/indexable.d.ts +0 -0
- {node v22.15 → node v22.18}/compatibility/iterators.d.ts +0 -0
- {node v22.15 → node v22.18}/console.d.ts +0 -0
- {node v22.15 → node v22.18}/constants.d.ts +0 -0
- {node v22.15 → node v22.18}/diagnostics_channel.d.ts +0 -0
- {node v22.15 → node v22.18}/domain.d.ts +0 -0
- {node v22.15 → node v22.18}/path.d.ts +0 -0
- {node v22.15 → node v22.18}/punycode.d.ts +0 -0
- {node v22.15 → node v22.18}/querystring.d.ts +0 -0
- {node v22.15 → node v22.18}/readline.d.ts +0 -0
- {node v22.15 → node v22.18}/sea.d.ts +0 -0
- {node v22.15 → node v22.18}/stream/promises.d.ts +0 -0
- {node v22.15 → node v22.18}/timers/promises.d.ts +0 -0
- {node v22.15 → node v22.18}/timers.d.ts +0 -0
- {node v22.15 → node v22.18}/trace_events.d.ts +0 -0
- {node v22.15 → node v22.18}/tty.d.ts +0 -0
|
@@ -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:
|
|
89
|
-
function createSocket(options: SocketOptions, callback?: (msg:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
@@ -127,24 +127,25 @@ declare module "dns/promises" {
|
|
|
127
127
|
* @param [rrtype='A'] Resource record type.
|
|
128
128
|
*/
|
|
129
129
|
function resolve(hostname: string): Promise<string[]>;
|
|
130
|
-
function resolve(hostname: string, rrtype: "A"): Promise<string[]>;
|
|
131
|
-
function resolve(hostname: string, rrtype: "AAAA"): Promise<string[]>;
|
|
130
|
+
function resolve(hostname: string, rrtype: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
|
|
132
131
|
function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
|
133
132
|
function resolve(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;
|
|
134
|
-
function resolve(hostname: string, rrtype: "CNAME"): Promise<string[]>;
|
|
135
133
|
function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
|
136
134
|
function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
|
137
|
-
function resolve(hostname: string, rrtype: "NS"): Promise<string[]>;
|
|
138
|
-
function resolve(hostname: string, rrtype: "PTR"): Promise<string[]>;
|
|
139
135
|
function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
|
140
136
|
function resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
|
141
137
|
function resolve(hostname: string, rrtype: "TLSA"): Promise<TlsaRecord[]>;
|
|
142
138
|
function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
|
143
|
-
function resolve(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
139
|
+
function resolve(hostname: string, rrtype: string): Promise<
|
|
140
|
+
| string[]
|
|
141
|
+
| CaaRecord[]
|
|
142
|
+
| MxRecord[]
|
|
143
|
+
| NaptrRecord[]
|
|
144
|
+
| SoaRecord
|
|
145
|
+
| SrvRecord[]
|
|
146
|
+
| TlsaRecord[]
|
|
147
|
+
| string[][]
|
|
148
|
+
| AnyRecord[]
|
|
148
149
|
>;
|
|
149
150
|
/**
|
|
150
151
|
* Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the `hostname`. On success, the `Promise` is resolved with an array of IPv4
|
|
@@ -250,6 +250,9 @@ declare module "dns" {
|
|
|
250
250
|
contactemail?: string | undefined;
|
|
251
251
|
contactphone?: string | undefined;
|
|
252
252
|
}
|
|
253
|
+
export interface AnyCaaRecord extends CaaRecord {
|
|
254
|
+
type: "CAA";
|
|
255
|
+
}
|
|
253
256
|
export interface MxRecord {
|
|
254
257
|
priority: number;
|
|
255
258
|
exchange: string;
|
|
@@ -317,6 +320,7 @@ declare module "dns" {
|
|
|
317
320
|
export type AnyRecord =
|
|
318
321
|
| AnyARecord
|
|
319
322
|
| AnyAaaaRecord
|
|
323
|
+
| AnyCaaRecord
|
|
320
324
|
| AnyCnameRecord
|
|
321
325
|
| AnyMxRecord
|
|
322
326
|
| AnyNaptrRecord
|
|
@@ -345,12 +349,7 @@ declare module "dns" {
|
|
|
345
349
|
): void;
|
|
346
350
|
export function resolve(
|
|
347
351
|
hostname: string,
|
|
348
|
-
rrtype: "A",
|
|
349
|
-
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
|
350
|
-
): void;
|
|
351
|
-
export function resolve(
|
|
352
|
-
hostname: string,
|
|
353
|
-
rrtype: "AAAA",
|
|
352
|
+
rrtype: "A" | "AAAA" | "CNAME" | "NS" | "PTR",
|
|
354
353
|
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
|
355
354
|
): void;
|
|
356
355
|
export function resolve(
|
|
@@ -360,8 +359,8 @@ declare module "dns" {
|
|
|
360
359
|
): void;
|
|
361
360
|
export function resolve(
|
|
362
361
|
hostname: string,
|
|
363
|
-
rrtype: "
|
|
364
|
-
callback: (err: NodeJS.ErrnoException | null,
|
|
362
|
+
rrtype: "CAA",
|
|
363
|
+
callback: (err: NodeJS.ErrnoException | null, address: CaaRecord[]) => void,
|
|
365
364
|
): void;
|
|
366
365
|
export function resolve(
|
|
367
366
|
hostname: string,
|
|
@@ -373,16 +372,6 @@ declare module "dns" {
|
|
|
373
372
|
rrtype: "NAPTR",
|
|
374
373
|
callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void,
|
|
375
374
|
): void;
|
|
376
|
-
export function resolve(
|
|
377
|
-
hostname: string,
|
|
378
|
-
rrtype: "NS",
|
|
379
|
-
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
|
380
|
-
): void;
|
|
381
|
-
export function resolve(
|
|
382
|
-
hostname: string,
|
|
383
|
-
rrtype: "PTR",
|
|
384
|
-
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
|
385
|
-
): void;
|
|
386
375
|
export function resolve(
|
|
387
376
|
hostname: string,
|
|
388
377
|
rrtype: "SOA",
|
|
@@ -410,6 +399,7 @@ declare module "dns" {
|
|
|
410
399
|
err: NodeJS.ErrnoException | null,
|
|
411
400
|
addresses:
|
|
412
401
|
| string[]
|
|
402
|
+
| CaaRecord[]
|
|
413
403
|
| MxRecord[]
|
|
414
404
|
| NaptrRecord[]
|
|
415
405
|
| SoaRecord
|
|
@@ -422,6 +412,7 @@ declare module "dns" {
|
|
|
422
412
|
export namespace resolve {
|
|
423
413
|
function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
|
|
424
414
|
function __promisify__(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
|
415
|
+
function __promisify__(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;
|
|
425
416
|
function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
|
426
417
|
function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
|
427
418
|
function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
|
@@ -432,7 +423,15 @@ declare module "dns" {
|
|
|
432
423
|
hostname: string,
|
|
433
424
|
rrtype: string,
|
|
434
425
|
): Promise<
|
|
435
|
-
|
|
426
|
+
| string[]
|
|
427
|
+
| CaaRecord[]
|
|
428
|
+
| MxRecord[]
|
|
429
|
+
| NaptrRecord[]
|
|
430
|
+
| SoaRecord
|
|
431
|
+
| SrvRecord[]
|
|
432
|
+
| TlsaRecord[]
|
|
433
|
+
| string[][]
|
|
434
|
+
| AnyRecord[]
|
|
436
435
|
>;
|
|
437
436
|
}
|
|
438
437
|
/**
|
|
@@ -830,7 +829,7 @@ declare module "dns" {
|
|
|
830
829
|
* The number of tries the resolver will try contacting each name server before giving up.
|
|
831
830
|
* @default 4
|
|
832
831
|
*/
|
|
833
|
-
tries?: number;
|
|
832
|
+
tries?: number | undefined;
|
|
834
833
|
}
|
|
835
834
|
/**
|
|
836
835
|
* An independent resolver for DNS requests.
|
|
@@ -36,39 +36,6 @@
|
|
|
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";
|
|
@@ -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,
|
|
@@ -40,7 +43,7 @@ declare module "fs/promises" {
|
|
|
40
43
|
StatsFs,
|
|
41
44
|
TimeLike,
|
|
42
45
|
WatchEventType,
|
|
43
|
-
WatchOptions,
|
|
46
|
+
WatchOptions as _WatchOptions,
|
|
44
47
|
WriteStream,
|
|
45
48
|
WriteVResult,
|
|
46
49
|
} from "node:fs";
|
|
@@ -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)`
|
|
@@ -88,6 +92,9 @@ declare module "fs/promises" {
|
|
|
88
92
|
highWaterMark?: number | undefined;
|
|
89
93
|
flush?: boolean | undefined;
|
|
90
94
|
}
|
|
95
|
+
interface ReadableWebStreamOptions {
|
|
96
|
+
autoClose?: boolean | undefined;
|
|
97
|
+
}
|
|
91
98
|
// TODO: Add `EventEmitter` close
|
|
92
99
|
interface FileHandle {
|
|
93
100
|
/**
|
|
@@ -232,11 +239,13 @@ declare module "fs/promises" {
|
|
|
232
239
|
length?: number | null,
|
|
233
240
|
position?: ReadPosition | null,
|
|
234
241
|
): Promise<FileReadResult<T>>;
|
|
235
|
-
read<T extends NodeJS.ArrayBufferView
|
|
242
|
+
read<T extends NodeJS.ArrayBufferView>(
|
|
236
243
|
buffer: T,
|
|
237
|
-
options?:
|
|
244
|
+
options?: ReadOptions,
|
|
245
|
+
): Promise<FileReadResult<T>>;
|
|
246
|
+
read<T extends NodeJS.ArrayBufferView = NonSharedBuffer>(
|
|
247
|
+
options?: ReadOptionsWithBuffer<T>,
|
|
238
248
|
): Promise<FileReadResult<T>>;
|
|
239
|
-
read<T extends NodeJS.ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
|
|
240
249
|
/**
|
|
241
250
|
* Returns a byte-oriented `ReadableStream` that may be used to read the file's
|
|
242
251
|
* contents.
|
|
@@ -260,9 +269,8 @@ declare module "fs/promises" {
|
|
|
260
269
|
* While the `ReadableStream` will read the file to completion, it will not
|
|
261
270
|
* close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method.
|
|
262
271
|
* @since v17.0.0
|
|
263
|
-
* @experimental
|
|
264
272
|
*/
|
|
265
|
-
readableWebStream(): ReadableStream;
|
|
273
|
+
readableWebStream(options?: ReadableWebStreamOptions): ReadableStream;
|
|
266
274
|
/**
|
|
267
275
|
* Asynchronously reads the entire contents of a file.
|
|
268
276
|
*
|
|
@@ -281,7 +289,7 @@ declare module "fs/promises" {
|
|
|
281
289
|
options?:
|
|
282
290
|
| ({ encoding?: null | undefined } & Abortable)
|
|
283
291
|
| null,
|
|
284
|
-
): Promise<
|
|
292
|
+
): Promise<NonSharedBuffer>;
|
|
285
293
|
/**
|
|
286
294
|
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
|
287
295
|
* The `FileHandle` must have been opened for reading.
|
|
@@ -300,7 +308,7 @@ declare module "fs/promises" {
|
|
|
300
308
|
| (ObjectEncodingOptions & Abortable)
|
|
301
309
|
| BufferEncoding
|
|
302
310
|
| null,
|
|
303
|
-
): Promise<string |
|
|
311
|
+
): Promise<string | NonSharedBuffer>;
|
|
304
312
|
/**
|
|
305
313
|
* Convenience method to create a `readline` interface and stream over the file.
|
|
306
314
|
* See `filehandle.createReadStream()` for the options.
|
|
@@ -409,7 +417,7 @@ declare module "fs/promises" {
|
|
|
409
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
|
|
410
418
|
* position. See the POSIX pwrite(2) documentation for more detail.
|
|
411
419
|
*/
|
|
412
|
-
write<TBuffer extends
|
|
420
|
+
write<TBuffer extends NodeJS.ArrayBufferView>(
|
|
413
421
|
buffer: TBuffer,
|
|
414
422
|
offset?: number | null,
|
|
415
423
|
length?: number | null,
|
|
@@ -448,14 +456,20 @@ declare module "fs/promises" {
|
|
|
448
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
|
|
449
457
|
* position.
|
|
450
458
|
*/
|
|
451
|
-
writev
|
|
459
|
+
writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
|
|
460
|
+
buffers: TBuffers,
|
|
461
|
+
position?: number,
|
|
462
|
+
): Promise<WriteVResult<TBuffers>>;
|
|
452
463
|
/**
|
|
453
464
|
* Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s
|
|
454
465
|
* @since v13.13.0, v12.17.0
|
|
455
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.
|
|
456
467
|
* @return Fulfills upon success an object containing two properties:
|
|
457
468
|
*/
|
|
458
|
-
readv
|
|
469
|
+
readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
|
|
470
|
+
buffers: TBuffers,
|
|
471
|
+
position?: number,
|
|
472
|
+
): Promise<ReadVResult<TBuffers>>;
|
|
459
473
|
/**
|
|
460
474
|
* Closes the file handle after waiting for any pending operation on the handle to
|
|
461
475
|
* complete.
|
|
@@ -475,7 +489,8 @@ declare module "fs/promises" {
|
|
|
475
489
|
*/
|
|
476
490
|
close(): Promise<void>;
|
|
477
491
|
/**
|
|
478
|
-
*
|
|
492
|
+
* Calls `filehandle.close()` and returns a promise that fulfills when the
|
|
493
|
+
* filehandle is closed.
|
|
479
494
|
* @since v20.4.0
|
|
480
495
|
*/
|
|
481
496
|
[Symbol.asyncDispose](): Promise<void>;
|
|
@@ -691,7 +706,7 @@ declare module "fs/promises" {
|
|
|
691
706
|
recursive?: boolean | undefined;
|
|
692
707
|
}
|
|
693
708
|
| "buffer",
|
|
694
|
-
): Promise<
|
|
709
|
+
): Promise<NonSharedBuffer[]>;
|
|
695
710
|
/**
|
|
696
711
|
* Asynchronous readdir(3) - read a directory.
|
|
697
712
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -706,7 +721,7 @@ declare module "fs/promises" {
|
|
|
706
721
|
})
|
|
707
722
|
| BufferEncoding
|
|
708
723
|
| null,
|
|
709
|
-
): Promise<string[] |
|
|
724
|
+
): Promise<string[] | NonSharedBuffer[]>;
|
|
710
725
|
/**
|
|
711
726
|
* Asynchronous readdir(3) - read a directory.
|
|
712
727
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -731,7 +746,7 @@ declare module "fs/promises" {
|
|
|
731
746
|
withFileTypes: true;
|
|
732
747
|
recursive?: boolean | undefined;
|
|
733
748
|
},
|
|
734
|
-
): Promise<Dirent<
|
|
749
|
+
): Promise<Dirent<NonSharedBuffer>[]>;
|
|
735
750
|
/**
|
|
736
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
|
|
737
752
|
* fulfilled with the`linkString` upon success.
|
|
@@ -749,13 +764,16 @@ declare module "fs/promises" {
|
|
|
749
764
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
750
765
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
751
766
|
*/
|
|
752
|
-
function readlink(path: PathLike, options: BufferEncodingOption): Promise<
|
|
767
|
+
function readlink(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
|
|
753
768
|
/**
|
|
754
769
|
* Asynchronous readlink(2) - read value of a symbolic link.
|
|
755
770
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
756
771
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
757
772
|
*/
|
|
758
|
-
function readlink(
|
|
773
|
+
function readlink(
|
|
774
|
+
path: PathLike,
|
|
775
|
+
options?: ObjectEncodingOptions | string | null,
|
|
776
|
+
): Promise<string | NonSharedBuffer>;
|
|
759
777
|
/**
|
|
760
778
|
* Creates a symbolic link.
|
|
761
779
|
*
|
|
@@ -906,7 +924,7 @@ declare module "fs/promises" {
|
|
|
906
924
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
907
925
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
908
926
|
*/
|
|
909
|
-
function realpath(path: PathLike, options: BufferEncodingOption): Promise<
|
|
927
|
+
function realpath(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
|
|
910
928
|
/**
|
|
911
929
|
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
|
912
930
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -915,7 +933,7 @@ declare module "fs/promises" {
|
|
|
915
933
|
function realpath(
|
|
916
934
|
path: PathLike,
|
|
917
935
|
options?: ObjectEncodingOptions | BufferEncoding | null,
|
|
918
|
-
): Promise<string |
|
|
936
|
+
): Promise<string | NonSharedBuffer>;
|
|
919
937
|
/**
|
|
920
938
|
* Creates a unique temporary directory. A unique directory name is generated by
|
|
921
939
|
* appending six random characters to the end of the provided `prefix`. Due to
|
|
@@ -951,13 +969,16 @@ declare module "fs/promises" {
|
|
|
951
969
|
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
|
952
970
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
953
971
|
*/
|
|
954
|
-
function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<
|
|
972
|
+
function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<NonSharedBuffer>;
|
|
955
973
|
/**
|
|
956
974
|
* Asynchronously creates a unique temporary directory.
|
|
957
975
|
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
|
958
976
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
|
959
977
|
*/
|
|
960
|
-
function mkdtemp(
|
|
978
|
+
function mkdtemp(
|
|
979
|
+
prefix: string,
|
|
980
|
+
options?: ObjectEncodingOptions | BufferEncoding | null,
|
|
981
|
+
): Promise<string | NonSharedBuffer>;
|
|
961
982
|
/**
|
|
962
983
|
* Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an
|
|
963
984
|
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an
|
|
@@ -1113,7 +1134,7 @@ declare module "fs/promises" {
|
|
|
1113
1134
|
flag?: OpenMode | undefined;
|
|
1114
1135
|
} & Abortable)
|
|
1115
1136
|
| null,
|
|
1116
|
-
): Promise<
|
|
1137
|
+
): Promise<NonSharedBuffer>;
|
|
1117
1138
|
/**
|
|
1118
1139
|
* Asynchronously reads the entire contents of a file.
|
|
1119
1140
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -1149,7 +1170,7 @@ declare module "fs/promises" {
|
|
|
1149
1170
|
)
|
|
1150
1171
|
| BufferEncoding
|
|
1151
1172
|
| null,
|
|
1152
|
-
): Promise<string |
|
|
1173
|
+
): Promise<string | NonSharedBuffer>;
|
|
1153
1174
|
/**
|
|
1154
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.
|
|
1155
1176
|
*
|
|
@@ -1179,6 +1200,16 @@ declare module "fs/promises" {
|
|
|
1179
1200
|
* @return Fulfills with an {fs.Dir}.
|
|
1180
1201
|
*/
|
|
1181
1202
|
function opendir(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
|
|
1203
|
+
interface WatchOptions extends _WatchOptions {
|
|
1204
|
+
maxQueue?: number | undefined;
|
|
1205
|
+
overflow?: "ignore" | "throw" | undefined;
|
|
1206
|
+
}
|
|
1207
|
+
interface WatchOptionsWithBufferEncoding extends WatchOptions {
|
|
1208
|
+
encoding: "buffer";
|
|
1209
|
+
}
|
|
1210
|
+
interface WatchOptionsWithStringEncoding extends WatchOptions {
|
|
1211
|
+
encoding?: BufferEncoding | undefined;
|
|
1212
|
+
}
|
|
1182
1213
|
/**
|
|
1183
1214
|
* Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
|
|
1184
1215
|
*
|
|
@@ -1211,33 +1242,16 @@ declare module "fs/promises" {
|
|
|
1211
1242
|
*/
|
|
1212
1243
|
function watch(
|
|
1213
1244
|
filename: PathLike,
|
|
1214
|
-
options
|
|
1215
|
-
|
|
1216
|
-
encoding: "buffer";
|
|
1217
|
-
})
|
|
1218
|
-
| "buffer",
|
|
1219
|
-
): AsyncIterable<FileChangeInfo<Buffer>>;
|
|
1220
|
-
/**
|
|
1221
|
-
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
|
1222
|
-
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
|
1223
|
-
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
|
|
1224
|
-
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
|
1225
|
-
* If `persistent` is not supplied, the default of `true` is used.
|
|
1226
|
-
* If `recursive` is not supplied, the default of `false` is used.
|
|
1227
|
-
*/
|
|
1228
|
-
function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable<FileChangeInfo<string>>;
|
|
1229
|
-
/**
|
|
1230
|
-
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
|
1231
|
-
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
|
1232
|
-
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
|
|
1233
|
-
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
|
1234
|
-
* If `persistent` is not supplied, the default of `true` is used.
|
|
1235
|
-
* If `recursive` is not supplied, the default of `false` is used.
|
|
1236
|
-
*/
|
|
1245
|
+
options?: WatchOptionsWithStringEncoding | BufferEncoding,
|
|
1246
|
+
): NodeJS.AsyncIterator<FileChangeInfo<string>>;
|
|
1237
1247
|
function watch(
|
|
1238
1248
|
filename: PathLike,
|
|
1239
|
-
options:
|
|
1240
|
-
):
|
|
1249
|
+
options: WatchOptionsWithBufferEncoding | "buffer",
|
|
1250
|
+
): NodeJS.AsyncIterator<FileChangeInfo<NonSharedBuffer>>;
|
|
1251
|
+
function watch(
|
|
1252
|
+
filename: PathLike,
|
|
1253
|
+
options: WatchOptions | BufferEncoding | "buffer",
|
|
1254
|
+
): NodeJS.AsyncIterator<FileChangeInfo<string | NonSharedBuffer>>;
|
|
1241
1255
|
/**
|
|
1242
1256
|
* Asynchronously copies the entire directory structure from `src` to `dest`,
|
|
1243
1257
|
* including subdirectories and files.
|
|
@@ -1252,20 +1266,28 @@ declare module "fs/promises" {
|
|
|
1252
1266
|
*/
|
|
1253
1267
|
function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
|
|
1254
1268
|
/**
|
|
1255
|
-
*
|
|
1269
|
+
* ```js
|
|
1270
|
+
* import { glob } from 'node:fs/promises';
|
|
1271
|
+
*
|
|
1272
|
+
* for await (const entry of glob('*.js'))
|
|
1273
|
+
* console.log(entry);
|
|
1274
|
+
* ```
|
|
1275
|
+
* @since v22.0.0
|
|
1276
|
+
* @returns An AsyncIterator that yields the paths of files
|
|
1277
|
+
* that match the pattern.
|
|
1256
1278
|
*/
|
|
1257
|
-
function glob(pattern: string | string[]): NodeJS.AsyncIterator<string>;
|
|
1279
|
+
function glob(pattern: string | readonly string[]): NodeJS.AsyncIterator<string>;
|
|
1258
1280
|
function glob(
|
|
1259
|
-
pattern: string | string[],
|
|
1260
|
-
|
|
1281
|
+
pattern: string | readonly string[],
|
|
1282
|
+
options: GlobOptionsWithFileTypes,
|
|
1261
1283
|
): NodeJS.AsyncIterator<Dirent>;
|
|
1262
1284
|
function glob(
|
|
1263
|
-
pattern: string | string[],
|
|
1264
|
-
|
|
1285
|
+
pattern: string | readonly string[],
|
|
1286
|
+
options: GlobOptionsWithoutFileTypes,
|
|
1265
1287
|
): NodeJS.AsyncIterator<string>;
|
|
1266
1288
|
function glob(
|
|
1267
|
-
pattern: string | string[],
|
|
1268
|
-
|
|
1289
|
+
pattern: string | readonly string[],
|
|
1290
|
+
options: GlobOptions,
|
|
1269
1291
|
): NodeJS.AsyncIterator<Dirent | string>;
|
|
1270
1292
|
}
|
|
1271
1293
|
declare module "node:fs/promises" {
|