@idlebox/stripe-node-types 24.0.14 → 24.0.15
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.
- package/README.md +1 -1
- package/assert/strict.d.ts +98 -1
- package/assert.d.ts +147 -248
- package/async_hooks.d.ts +5 -5
- package/buffer.buffer.d.ts +9 -6
- package/buffer.d.ts +49 -169
- package/child_process.d.ts +102 -223
- package/cluster.d.ts +236 -329
- package/console.d.ts +45 -346
- package/constants.d.ts +0 -1
- package/crypto.d.ts +698 -1149
- package/dgram.d.ts +15 -50
- package/diagnostics_channel.d.ts +1 -3
- package/dns.d.ts +135 -131
- package/domain.d.ts +10 -14
- package/events.d.ts +846 -722
- package/fs/promises.d.ts +102 -53
- package/fs.d.ts +714 -484
- package/globals.d.ts +130 -347
- package/globals.typedarray.d.ts +79 -0
- package/http.d.ts +343 -246
- package/http2.d.ts +563 -711
- package/https.d.ts +70 -216
- package/index.d.ts +24 -3
- package/inspector/promises.d.ts +54 -0
- package/inspector.d.ts +167 -3938
- package/inspector.generated.d.ts +4242 -0
- package/module.d.ts +45 -95
- package/net.d.ts +87 -186
- package/os.d.ts +17 -6
- package/package.json +3 -8
- package/path/posix.d.ts +20 -0
- package/path/win32.d.ts +20 -0
- package/path.d.ts +117 -122
- package/perf_hooks.d.ts +295 -644
- package/process.d.ts +177 -138
- package/punycode.d.ts +2 -2
- package/querystring.d.ts +1 -1
- package/quic.d.ts +926 -0
- package/readline/promises.d.ts +1 -1
- package/readline.d.ts +65 -118
- package/repl.d.ts +83 -96
- package/sea.d.ts +10 -1
- package/sqlite.d.ts +262 -13
- package/stream/consumers.d.ts +7 -7
- package/stream/promises.d.ts +133 -12
- package/stream/web.d.ts +173 -495
- package/stream.d.ts +593 -490
- package/string_decoder.d.ts +3 -3
- package/test/reporters.d.ts +112 -0
- package/test.d.ts +223 -199
- package/timers/promises.d.ts +1 -1
- package/timers.d.ts +1 -129
- package/tls.d.ts +148 -163
- package/trace_events.d.ts +6 -6
- package/ts5.6/buffer.buffer.d.ts +10 -8
- package/ts5.6/globals.typedarray.d.ts +16 -0
- package/ts5.6/index.d.ts +24 -3
- package/ts5.7/index.d.ts +24 -3
- package/tty.d.ts +55 -13
- package/url.d.ts +92 -587
- package/util/types.d.ts +571 -0
- package/util.d.ts +143 -792
- package/v8.d.ts +67 -7
- package/vm.d.ts +252 -108
- package/wasi.d.ts +23 -2
- package/web-globals/abortcontroller.d.ts +75 -0
- package/web-globals/blob.d.ts +39 -0
- package/{ts5.1/compatibility/disposable.d.ts → web-globals/console.d.ts} +6 -9
- package/web-globals/crypto.d.ts +55 -0
- package/web-globals/domexception.d.ts +84 -0
- package/web-globals/encoding.d.ts +27 -0
- package/{dom-events.d.ts → web-globals/events.d.ts} +57 -50
- package/web-globals/fetch.d.ts +70 -0
- package/web-globals/importmeta.d.ts +29 -0
- package/web-globals/messaging.d.ts +39 -0
- package/web-globals/navigator.d.ts +41 -0
- package/web-globals/performance.d.ts +61 -0
- package/web-globals/storage.d.ts +40 -0
- package/web-globals/streams.d.ts +131 -0
- package/web-globals/timers.d.ts +60 -0
- package/web-globals/url.d.ts +40 -0
- package/worker_threads.d.ts +291 -349
- package/zlib.d.ts +44 -94
- package/ts5.1/index.d.ts +0 -115
package/stream.d.ts
CHANGED
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
* A stream is an abstract interface for working with streaming data in Node.js.
|
|
18
18
|
* The `node:stream` module provides an API for implementing the stream interface.
|
|
19
19
|
*
|
|
20
|
-
* There are many stream objects provided by Node.js. For instance, a [request to an HTTP server](https://nodejs.org/docs/latest-
|
|
21
|
-
* and [`process.stdout`](https://nodejs.org/docs/latest-
|
|
20
|
+
* There are many stream objects provided by Node.js. For instance, a [request to an HTTP server](https://nodejs.org/docs/latest-v25.x/api/http.html#class-httpincomingmessage)
|
|
21
|
+
* and [`process.stdout`](https://nodejs.org/docs/latest-v25.x/api/process.html#processstdout) are both stream instances.
|
|
22
22
|
*
|
|
23
|
-
* Streams can be readable, writable, or both. All streams are instances of [`EventEmitter`](https://nodejs.org/docs/latest-
|
|
23
|
+
* Streams can be readable, writable, or both. All streams are instances of [`EventEmitter`](https://nodejs.org/docs/latest-v25.x/api/events.html#class-eventemitter).
|
|
24
24
|
*
|
|
25
25
|
* To access the `node:stream` module:
|
|
26
26
|
*
|
|
@@ -30,58 +30,88 @@
|
|
|
30
30
|
*
|
|
31
31
|
* The `node:stream` module is useful for creating new types of stream instances.
|
|
32
32
|
* It is usually not necessary to use the `node:stream` module to consume streams.
|
|
33
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
33
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/stream.js)
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
declare module "node:stream" {
|
|
37
|
+
import { Blob } from 'node:buffer';
|
|
37
38
|
import { Abortable, EventEmitter } from 'node:events';
|
|
38
|
-
import
|
|
39
|
-
import * as
|
|
40
|
-
import * as streamWeb from 'node:stream/web';
|
|
41
|
-
|
|
42
|
-
type ComposeFnParam = (source: any) => void;
|
|
43
|
-
|
|
39
|
+
import * as promises from 'node:stream/promises';
|
|
40
|
+
import * as web from 'node:stream/web';
|
|
44
41
|
class Stream extends EventEmitter {
|
|
42
|
+
/**
|
|
43
|
+
* @since v0.9.4
|
|
44
|
+
*/
|
|
45
45
|
pipe<T extends NodeJS.WritableStream>(
|
|
46
46
|
destination: T,
|
|
47
|
-
options?:
|
|
48
|
-
end?: boolean | undefined;
|
|
49
|
-
},
|
|
50
|
-
): T;
|
|
51
|
-
compose<T extends NodeJS.ReadableStream>(
|
|
52
|
-
stream: T | ComposeFnParam | Iterable<T> | AsyncIterable<T>,
|
|
53
|
-
options?: { signal: AbortSignal },
|
|
47
|
+
options?: Stream.PipeOptions,
|
|
54
48
|
): T;
|
|
55
49
|
}
|
|
56
50
|
namespace Stream {
|
|
57
|
-
export {
|
|
51
|
+
export { promises, Stream };
|
|
58
52
|
}
|
|
59
53
|
namespace Stream {
|
|
54
|
+
interface PipeOptions {
|
|
55
|
+
/**
|
|
56
|
+
* End the writer when the reader ends.
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
end?: boolean | undefined;
|
|
60
|
+
}
|
|
60
61
|
interface StreamOptions<T extends Stream> extends Abortable {
|
|
61
62
|
emitClose?: boolean | undefined;
|
|
62
63
|
highWaterMark?: number | undefined;
|
|
63
64
|
objectMode?: boolean | undefined;
|
|
64
|
-
construct
|
|
65
|
-
destroy
|
|
65
|
+
construct?: ((this: T, callback: (error?: Error | null) => void) => void) | undefined;
|
|
66
|
+
destroy?: ((this: T, error: Error | null, callback: (error?: Error | null) => void) => void) | undefined;
|
|
66
67
|
autoDestroy?: boolean | undefined;
|
|
67
68
|
}
|
|
68
69
|
interface ReadableOptions<T extends Readable = Readable> extends StreamOptions<T> {
|
|
69
70
|
encoding?: BufferEncoding | undefined;
|
|
70
|
-
read
|
|
71
|
+
read?: ((this: T, size: number) => void) | undefined;
|
|
71
72
|
}
|
|
72
|
-
interface
|
|
73
|
+
interface ReadableIteratorOptions {
|
|
73
74
|
/**
|
|
74
|
-
*
|
|
75
|
+
* When set to `false`, calling `return` on the async iterator,
|
|
76
|
+
* or exiting a `for await...of` iteration using a `break`,
|
|
77
|
+
* `return`, or `throw` will not destroy the stream.
|
|
78
|
+
* @default true
|
|
79
|
+
*/
|
|
80
|
+
destroyOnReturn?: boolean | undefined;
|
|
81
|
+
}
|
|
82
|
+
interface ReadableOperatorOptions extends Abortable {
|
|
83
|
+
/**
|
|
84
|
+
* The maximum concurrent invocations of `fn` to call
|
|
85
|
+
* on the stream at once.
|
|
75
86
|
* @default 1
|
|
76
87
|
*/
|
|
77
|
-
concurrency?: number;
|
|
78
|
-
/**
|
|
79
|
-
|
|
88
|
+
concurrency?: number | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* How many items to buffer while waiting for user consumption
|
|
91
|
+
* of the output.
|
|
92
|
+
* @default concurrency * 2 - 1
|
|
93
|
+
*/
|
|
94
|
+
highWaterMark?: number | undefined;
|
|
95
|
+
}
|
|
96
|
+
/** @deprecated Use `ReadableOperatorOptions` instead. */
|
|
97
|
+
interface ArrayOptions extends ReadableOperatorOptions {}
|
|
98
|
+
interface ReadableToWebOptions {
|
|
99
|
+
strategy?: web.QueuingStrategy | undefined;
|
|
100
|
+
}
|
|
101
|
+
interface ReadableEventMap {
|
|
102
|
+
"close": [];
|
|
103
|
+
"data": [chunk: any];
|
|
104
|
+
"end": [];
|
|
105
|
+
"error": [err: Error];
|
|
106
|
+
"pause": [];
|
|
107
|
+
"readable": [];
|
|
108
|
+
"resume": [];
|
|
80
109
|
}
|
|
81
110
|
/**
|
|
82
111
|
* @since v0.9.4
|
|
83
112
|
*/
|
|
84
113
|
class Readable extends Stream implements NodeJS.ReadableStream {
|
|
114
|
+
constructor(options?: ReadableOptions);
|
|
85
115
|
/**
|
|
86
116
|
* A utility method for creating Readable Streams out of iterators.
|
|
87
117
|
* @since v12.3.0, v10.17.0
|
|
@@ -94,7 +124,7 @@ declare module "node:stream" {
|
|
|
94
124
|
* @since v17.0.0
|
|
95
125
|
*/
|
|
96
126
|
static fromWeb(
|
|
97
|
-
readableStream:
|
|
127
|
+
readableStream: web.ReadableStream,
|
|
98
128
|
options?: Pick<ReadableOptions, "encoding" | "highWaterMark" | "objectMode" | "signal">,
|
|
99
129
|
): Readable;
|
|
100
130
|
/**
|
|
@@ -102,16 +132,14 @@ declare module "node:stream" {
|
|
|
102
132
|
* @since v17.0.0
|
|
103
133
|
*/
|
|
104
134
|
static toWeb(
|
|
105
|
-
streamReadable:
|
|
106
|
-
options?:
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
): streamWeb.ReadableStream;
|
|
135
|
+
streamReadable: NodeJS.ReadableStream,
|
|
136
|
+
options?: ReadableToWebOptions,
|
|
137
|
+
): web.ReadableStream;
|
|
110
138
|
/**
|
|
111
139
|
* Returns whether the stream has been read from or cancelled.
|
|
112
140
|
* @since v16.8.0
|
|
113
141
|
*/
|
|
114
|
-
static isDisturbed(stream:
|
|
142
|
+
static isDisturbed(stream: NodeJS.ReadableStream | web.ReadableStream): boolean;
|
|
115
143
|
/**
|
|
116
144
|
* Returns whether the stream was destroyed or errored before emitting `'end'`.
|
|
117
145
|
* @since v16.8.0
|
|
@@ -134,16 +162,16 @@ declare module "node:stream" {
|
|
|
134
162
|
*/
|
|
135
163
|
readonly readableEncoding: BufferEncoding | null;
|
|
136
164
|
/**
|
|
137
|
-
* Becomes `true` when [`'end'`](https://nodejs.org/docs/latest-
|
|
165
|
+
* Becomes `true` when [`'end'`](https://nodejs.org/docs/latest-v25.x/api/stream.html#event-end) event is emitted.
|
|
138
166
|
* @since v12.9.0
|
|
139
167
|
*/
|
|
140
168
|
readonly readableEnded: boolean;
|
|
141
169
|
/**
|
|
142
170
|
* This property reflects the current state of a `Readable` stream as described
|
|
143
|
-
* in the [Three states](https://nodejs.org/docs/latest-
|
|
171
|
+
* in the [Three states](https://nodejs.org/docs/latest-v25.x/api/stream.html#three-states) section.
|
|
144
172
|
* @since v9.4.0
|
|
145
173
|
*/
|
|
146
|
-
|
|
174
|
+
readableFlowing: boolean | null;
|
|
147
175
|
/**
|
|
148
176
|
* Returns the value of `highWaterMark` passed when creating this `Readable`.
|
|
149
177
|
* @since v9.3.0
|
|
@@ -176,7 +204,6 @@ declare module "node:stream" {
|
|
|
176
204
|
* @since v18.0.0
|
|
177
205
|
*/
|
|
178
206
|
readonly errored: Error | null;
|
|
179
|
-
constructor(opts?: ReadableOptions);
|
|
180
207
|
_construct?(callback: (error?: Error | null) => void): void;
|
|
181
208
|
_read(size: number): void;
|
|
182
209
|
/**
|
|
@@ -460,16 +487,41 @@ declare module "node:stream" {
|
|
|
460
487
|
*/
|
|
461
488
|
wrap(stream: NodeJS.ReadableStream): this;
|
|
462
489
|
push(chunk: any, encoding?: BufferEncoding): boolean;
|
|
490
|
+
/**
|
|
491
|
+
* ```js
|
|
492
|
+
* import { Readable } from 'node:stream';
|
|
493
|
+
*
|
|
494
|
+
* async function* splitToWords(source) {
|
|
495
|
+
* for await (const chunk of source) {
|
|
496
|
+
* const words = String(chunk).split(' ');
|
|
497
|
+
*
|
|
498
|
+
* for (const word of words) {
|
|
499
|
+
* yield word;
|
|
500
|
+
* }
|
|
501
|
+
* }
|
|
502
|
+
* }
|
|
503
|
+
*
|
|
504
|
+
* const wordsStream = Readable.from(['this is', 'compose as operator']).compose(splitToWords);
|
|
505
|
+
* const words = await wordsStream.toArray();
|
|
506
|
+
*
|
|
507
|
+
* console.log(words); // prints ['this', 'is', 'compose', 'as', 'operator']
|
|
508
|
+
* ```
|
|
509
|
+
*
|
|
510
|
+
* See [`stream.compose`](https://nodejs.org/docs/latest-v25.x/api/stream.html#streamcomposestreams) for more information.
|
|
511
|
+
* @since v19.1.0, v18.13.0
|
|
512
|
+
* @returns a stream composed with the stream `stream`.
|
|
513
|
+
*/
|
|
514
|
+
compose(
|
|
515
|
+
stream: NodeJS.WritableStream | web.WritableStream | web.TransformStream | ((source: any) => void),
|
|
516
|
+
options?: Abortable,
|
|
517
|
+
): Duplex;
|
|
463
518
|
/**
|
|
464
519
|
* The iterator created by this method gives users the option to cancel the destruction
|
|
465
520
|
* of the stream if the `for await...of` loop is exited by `return`, `break`, or `throw`,
|
|
466
521
|
* or if the iterator should destroy the stream if the stream emitted an error during iteration.
|
|
467
522
|
* @since v16.3.0
|
|
468
|
-
* @param options.destroyOnReturn When set to `false`, calling `return` on the async iterator,
|
|
469
|
-
* or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream.
|
|
470
|
-
* **Default: `true`**.
|
|
471
523
|
*/
|
|
472
|
-
iterator(options?:
|
|
524
|
+
iterator(options?: ReadableIteratorOptions): NodeJS.AsyncIterator<any>;
|
|
473
525
|
/**
|
|
474
526
|
* This method allows mapping over the stream. The *fn* function will be called for every chunk in the stream.
|
|
475
527
|
* If the *fn* function returns a promise - that promise will be `await`ed before being passed to the result stream.
|
|
@@ -477,7 +529,7 @@ declare module "node:stream" {
|
|
|
477
529
|
* @param fn a function to map over every chunk in the stream. Async or not.
|
|
478
530
|
* @returns a stream mapped with the function *fn*.
|
|
479
531
|
*/
|
|
480
|
-
map(fn: (data: any, options?:
|
|
532
|
+
map(fn: (data: any, options?: Abortable) => any, options?: ReadableOperatorOptions): Readable;
|
|
481
533
|
/**
|
|
482
534
|
* This method allows filtering the stream. For each chunk in the stream the *fn* function will be called
|
|
483
535
|
* and if it returns a truthy value, the chunk will be passed to the result stream.
|
|
@@ -487,8 +539,8 @@ declare module "node:stream" {
|
|
|
487
539
|
* @returns a stream filtered with the predicate *fn*.
|
|
488
540
|
*/
|
|
489
541
|
filter(
|
|
490
|
-
fn: (data: any, options?:
|
|
491
|
-
options?:
|
|
542
|
+
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
543
|
+
options?: ReadableOperatorOptions,
|
|
492
544
|
): Readable;
|
|
493
545
|
/**
|
|
494
546
|
* This method allows iterating a stream. For each chunk in the stream the *fn* function will be called.
|
|
@@ -506,8 +558,8 @@ declare module "node:stream" {
|
|
|
506
558
|
* @returns a promise for when the stream has finished.
|
|
507
559
|
*/
|
|
508
560
|
forEach(
|
|
509
|
-
fn: (data: any, options?:
|
|
510
|
-
options?:
|
|
561
|
+
fn: (data: any, options?: Abortable) => void | Promise<void>,
|
|
562
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
511
563
|
): Promise<void>;
|
|
512
564
|
/**
|
|
513
565
|
* This method allows easily obtaining the contents of a stream.
|
|
@@ -517,7 +569,7 @@ declare module "node:stream" {
|
|
|
517
569
|
* @since v17.5.0
|
|
518
570
|
* @returns a promise containing an array with the contents of the stream.
|
|
519
571
|
*/
|
|
520
|
-
toArray(options?:
|
|
572
|
+
toArray(options?: Abortable): Promise<any[]>;
|
|
521
573
|
/**
|
|
522
574
|
* This method is similar to `Array.prototype.some` and calls *fn* on each chunk in the stream
|
|
523
575
|
* until the awaited return value is `true` (or any truthy value). Once an *fn* call on a chunk
|
|
@@ -528,8 +580,8 @@ declare module "node:stream" {
|
|
|
528
580
|
* @returns a promise evaluating to `true` if *fn* returned a truthy value for at least one of the chunks.
|
|
529
581
|
*/
|
|
530
582
|
some(
|
|
531
|
-
fn: (data: any, options?:
|
|
532
|
-
options?:
|
|
583
|
+
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
584
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
533
585
|
): Promise<boolean>;
|
|
534
586
|
/**
|
|
535
587
|
* This method is similar to `Array.prototype.find` and calls *fn* on each chunk in the stream
|
|
@@ -542,12 +594,12 @@ declare module "node:stream" {
|
|
|
542
594
|
* or `undefined` if no element was found.
|
|
543
595
|
*/
|
|
544
596
|
find<T>(
|
|
545
|
-
fn: (data: any, options?:
|
|
546
|
-
options?:
|
|
597
|
+
fn: (data: any, options?: Abortable) => data is T,
|
|
598
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
547
599
|
): Promise<T | undefined>;
|
|
548
600
|
find(
|
|
549
|
-
fn: (data: any, options?:
|
|
550
|
-
options?:
|
|
601
|
+
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
602
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
551
603
|
): Promise<any>;
|
|
552
604
|
/**
|
|
553
605
|
* This method is similar to `Array.prototype.every` and calls *fn* on each chunk in the stream
|
|
@@ -559,8 +611,8 @@ declare module "node:stream" {
|
|
|
559
611
|
* @returns a promise evaluating to `true` if *fn* returned a truthy value for every one of the chunks.
|
|
560
612
|
*/
|
|
561
613
|
every(
|
|
562
|
-
fn: (data: any, options?:
|
|
563
|
-
options?:
|
|
614
|
+
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
615
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
564
616
|
): Promise<boolean>;
|
|
565
617
|
/**
|
|
566
618
|
* This method returns a new stream by applying the given callback to each chunk of the stream
|
|
@@ -572,28 +624,24 @@ declare module "node:stream" {
|
|
|
572
624
|
* @param fn a function to map over every chunk in the stream. May be async. May be a stream or generator.
|
|
573
625
|
* @returns a stream flat-mapped with the function *fn*.
|
|
574
626
|
*/
|
|
575
|
-
flatMap(
|
|
627
|
+
flatMap(
|
|
628
|
+
fn: (data: any, options?: Abortable) => any,
|
|
629
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
630
|
+
): Readable;
|
|
576
631
|
/**
|
|
577
632
|
* This method returns a new stream with the first *limit* chunks dropped from the start.
|
|
578
633
|
* @since v17.5.0
|
|
579
634
|
* @param limit the number of chunks to drop from the readable.
|
|
580
635
|
* @returns a stream with *limit* chunks dropped from the start.
|
|
581
636
|
*/
|
|
582
|
-
drop(limit: number, options?:
|
|
637
|
+
drop(limit: number, options?: Abortable): Readable;
|
|
583
638
|
/**
|
|
584
639
|
* This method returns a new stream with the first *limit* chunks.
|
|
585
640
|
* @since v17.5.0
|
|
586
641
|
* @param limit the number of chunks to take from the readable.
|
|
587
642
|
* @returns a stream with *limit* chunks taken.
|
|
588
643
|
*/
|
|
589
|
-
take(limit: number, options?:
|
|
590
|
-
/**
|
|
591
|
-
* This method returns a new stream with chunks of the underlying stream paired with a counter
|
|
592
|
-
* in the form `[index, chunk]`. The first index value is `0` and it increases by 1 for each chunk produced.
|
|
593
|
-
* @since v17.5.0
|
|
594
|
-
* @returns a stream of indexed pairs.
|
|
595
|
-
*/
|
|
596
|
-
asIndexedPairs(options?: Pick<ArrayOptions, "signal">): Readable;
|
|
644
|
+
take(limit: number, options?: Abortable): Readable;
|
|
597
645
|
/**
|
|
598
646
|
* This method calls *fn* on each chunk of the stream in order, passing it the result from the calculation
|
|
599
647
|
* on the previous element. It returns a promise for the final value of the reduction.
|
|
@@ -608,15 +656,11 @@ declare module "node:stream" {
|
|
|
608
656
|
* @param initial the initial value to use in the reduction.
|
|
609
657
|
* @returns a promise for the final value of the reduction.
|
|
610
658
|
*/
|
|
611
|
-
reduce<T
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
options?: Pick<ArrayOptions, "signal">,
|
|
615
|
-
): Promise<T>;
|
|
616
|
-
reduce<T = any>(
|
|
617
|
-
fn: (previous: T, data: any, options?: Pick<ArrayOptions, "signal">) => T,
|
|
659
|
+
reduce<T>(fn: (previous: any, data: any, options?: Abortable) => T): Promise<T>;
|
|
660
|
+
reduce<T>(
|
|
661
|
+
fn: (previous: T, data: any, options?: Abortable) => T,
|
|
618
662
|
initial: T,
|
|
619
|
-
options?:
|
|
663
|
+
options?: Abortable,
|
|
620
664
|
): Promise<T>;
|
|
621
665
|
_destroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
|
622
666
|
/**
|
|
@@ -632,121 +676,117 @@ declare module "node:stream" {
|
|
|
632
676
|
*/
|
|
633
677
|
destroy(error?: Error): this;
|
|
634
678
|
/**
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
|
|
638
|
-
* 2. data
|
|
639
|
-
* 3. end
|
|
640
|
-
* 4. error
|
|
641
|
-
* 5. pause
|
|
642
|
-
* 6. readable
|
|
643
|
-
* 7. resume
|
|
644
|
-
*/
|
|
645
|
-
addListener(event: "close", listener: () => void): this;
|
|
646
|
-
addListener(event: "data", listener: (chunk: any) => void): this;
|
|
647
|
-
addListener(event: "end", listener: () => void): this;
|
|
648
|
-
addListener(event: "error", listener: (err: Error) => void): this;
|
|
649
|
-
addListener(event: "pause", listener: () => void): this;
|
|
650
|
-
addListener(event: "readable", listener: () => void): this;
|
|
651
|
-
addListener(event: "resume", listener: () => void): this;
|
|
652
|
-
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
653
|
-
emit(event: "close"): boolean;
|
|
654
|
-
emit(event: "data", chunk: any): boolean;
|
|
655
|
-
emit(event: "end"): boolean;
|
|
656
|
-
emit(event: "error", err: Error): boolean;
|
|
657
|
-
emit(event: "pause"): boolean;
|
|
658
|
-
emit(event: "readable"): boolean;
|
|
659
|
-
emit(event: "resume"): boolean;
|
|
660
|
-
emit(event: string | symbol, ...args: any[]): boolean;
|
|
661
|
-
on(event: "close", listener: () => void): this;
|
|
662
|
-
on(event: "data", listener: (chunk: any) => void): this;
|
|
663
|
-
on(event: "end", listener: () => void): this;
|
|
664
|
-
on(event: "error", listener: (err: Error) => void): this;
|
|
665
|
-
on(event: "pause", listener: () => void): this;
|
|
666
|
-
on(event: "readable", listener: () => void): this;
|
|
667
|
-
on(event: "resume", listener: () => void): this;
|
|
668
|
-
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
669
|
-
once(event: "close", listener: () => void): this;
|
|
670
|
-
once(event: "data", listener: (chunk: any) => void): this;
|
|
671
|
-
once(event: "end", listener: () => void): this;
|
|
672
|
-
once(event: "error", listener: (err: Error) => void): this;
|
|
673
|
-
once(event: "pause", listener: () => void): this;
|
|
674
|
-
once(event: "readable", listener: () => void): this;
|
|
675
|
-
once(event: "resume", listener: () => void): this;
|
|
676
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
677
|
-
prependListener(event: "close", listener: () => void): this;
|
|
678
|
-
prependListener(event: "data", listener: (chunk: any) => void): this;
|
|
679
|
-
prependListener(event: "end", listener: () => void): this;
|
|
680
|
-
prependListener(event: "error", listener: (err: Error) => void): this;
|
|
681
|
-
prependListener(event: "pause", listener: () => void): this;
|
|
682
|
-
prependListener(event: "readable", listener: () => void): this;
|
|
683
|
-
prependListener(event: "resume", listener: () => void): this;
|
|
684
|
-
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
685
|
-
prependOnceListener(event: "close", listener: () => void): this;
|
|
686
|
-
prependOnceListener(event: "data", listener: (chunk: any) => void): this;
|
|
687
|
-
prependOnceListener(event: "end", listener: () => void): this;
|
|
688
|
-
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
|
689
|
-
prependOnceListener(event: "pause", listener: () => void): this;
|
|
690
|
-
prependOnceListener(event: "readable", listener: () => void): this;
|
|
691
|
-
prependOnceListener(event: "resume", listener: () => void): this;
|
|
692
|
-
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
693
|
-
removeListener(event: "close", listener: () => void): this;
|
|
694
|
-
removeListener(event: "data", listener: (chunk: any) => void): this;
|
|
695
|
-
removeListener(event: "end", listener: () => void): this;
|
|
696
|
-
removeListener(event: "error", listener: (err: Error) => void): this;
|
|
697
|
-
removeListener(event: "pause", listener: () => void): this;
|
|
698
|
-
removeListener(event: "readable", listener: () => void): this;
|
|
699
|
-
removeListener(event: "resume", listener: () => void): this;
|
|
700
|
-
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
679
|
+
* @returns `AsyncIterator` to fully consume the stream.
|
|
680
|
+
* @since v10.0.0
|
|
681
|
+
*/
|
|
701
682
|
[Symbol.asyncIterator](): NodeJS.AsyncIterator<any>;
|
|
702
683
|
/**
|
|
703
|
-
* Calls `readable.destroy()` with an `AbortError` and returns
|
|
684
|
+
* Calls `readable.destroy()` with an `AbortError` and returns
|
|
685
|
+
* a promise that fulfills when the stream is finished.
|
|
704
686
|
* @since v20.4.0
|
|
705
687
|
*/
|
|
706
688
|
[Symbol.asyncDispose](): Promise<void>;
|
|
689
|
+
// #region InternalEventEmitter
|
|
690
|
+
addListener<E extends keyof ReadableEventMap>(
|
|
691
|
+
eventName: E,
|
|
692
|
+
listener: (...args: ReadableEventMap[E]) => void,
|
|
693
|
+
): this;
|
|
694
|
+
addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
695
|
+
emit<E extends keyof ReadableEventMap>(eventName: E, ...args: ReadableEventMap[E]): boolean;
|
|
696
|
+
emit(eventName: string | symbol, ...args: any[]): boolean;
|
|
697
|
+
listenerCount<E extends keyof ReadableEventMap>(
|
|
698
|
+
eventName: E,
|
|
699
|
+
listener?: (...args: ReadableEventMap[E]) => void,
|
|
700
|
+
): number;
|
|
701
|
+
listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number;
|
|
702
|
+
listeners<E extends keyof ReadableEventMap>(eventName: E): ((...args: ReadableEventMap[E]) => void)[];
|
|
703
|
+
listeners(eventName: string | symbol): ((...args: any[]) => void)[];
|
|
704
|
+
off<E extends keyof ReadableEventMap>(eventName: E, listener: (...args: ReadableEventMap[E]) => void): this;
|
|
705
|
+
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
706
|
+
on<E extends keyof ReadableEventMap>(eventName: E, listener: (...args: ReadableEventMap[E]) => void): this;
|
|
707
|
+
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
708
|
+
once<E extends keyof ReadableEventMap>(
|
|
709
|
+
eventName: E,
|
|
710
|
+
listener: (...args: ReadableEventMap[E]) => void,
|
|
711
|
+
): this;
|
|
712
|
+
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
713
|
+
prependListener<E extends keyof ReadableEventMap>(
|
|
714
|
+
eventName: E,
|
|
715
|
+
listener: (...args: ReadableEventMap[E]) => void,
|
|
716
|
+
): this;
|
|
717
|
+
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
718
|
+
prependOnceListener<E extends keyof ReadableEventMap>(
|
|
719
|
+
eventName: E,
|
|
720
|
+
listener: (...args: ReadableEventMap[E]) => void,
|
|
721
|
+
): this;
|
|
722
|
+
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
723
|
+
rawListeners<E extends keyof ReadableEventMap>(eventName: E): ((...args: ReadableEventMap[E]) => void)[];
|
|
724
|
+
rawListeners(eventName: string | symbol): ((...args: any[]) => void)[];
|
|
725
|
+
// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
|
726
|
+
removeAllListeners<E extends keyof ReadableEventMap>(eventName?: E): this;
|
|
727
|
+
removeAllListeners(eventName?: string | symbol): this;
|
|
728
|
+
removeListener<E extends keyof ReadableEventMap>(
|
|
729
|
+
eventName: E,
|
|
730
|
+
listener: (...args: ReadableEventMap[E]) => void,
|
|
731
|
+
): this;
|
|
732
|
+
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
733
|
+
// #endregion
|
|
707
734
|
}
|
|
708
735
|
interface WritableOptions<T extends Writable = Writable> extends StreamOptions<T> {
|
|
709
736
|
decodeStrings?: boolean | undefined;
|
|
710
737
|
defaultEncoding?: BufferEncoding | undefined;
|
|
711
|
-
write
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
738
|
+
write?:
|
|
739
|
+
| ((
|
|
740
|
+
this: T,
|
|
741
|
+
chunk: any,
|
|
742
|
+
encoding: BufferEncoding,
|
|
743
|
+
callback: (error?: Error | null) => void,
|
|
744
|
+
) => void)
|
|
745
|
+
| undefined;
|
|
746
|
+
writev?:
|
|
747
|
+
| ((
|
|
748
|
+
this: T,
|
|
749
|
+
chunks: {
|
|
750
|
+
chunk: any;
|
|
751
|
+
encoding: BufferEncoding;
|
|
752
|
+
}[],
|
|
753
|
+
callback: (error?: Error | null) => void,
|
|
754
|
+
) => void)
|
|
755
|
+
| undefined;
|
|
756
|
+
final?: ((this: T, callback: (error?: Error | null) => void) => void) | undefined;
|
|
757
|
+
}
|
|
758
|
+
interface WritableEventMap {
|
|
759
|
+
"close": [];
|
|
760
|
+
"drain": [];
|
|
761
|
+
"error": [err: Error];
|
|
762
|
+
"finish": [];
|
|
763
|
+
"pipe": [src: Readable];
|
|
764
|
+
"unpipe": [src: Readable];
|
|
726
765
|
}
|
|
727
766
|
/**
|
|
728
767
|
* @since v0.9.4
|
|
729
768
|
*/
|
|
730
769
|
class Writable extends Stream implements NodeJS.WritableStream {
|
|
770
|
+
constructor(options?: WritableOptions);
|
|
731
771
|
/**
|
|
732
772
|
* A utility method for creating a `Writable` from a web `WritableStream`.
|
|
733
773
|
* @since v17.0.0
|
|
734
774
|
*/
|
|
735
775
|
static fromWeb(
|
|
736
|
-
writableStream:
|
|
776
|
+
writableStream: web.WritableStream,
|
|
737
777
|
options?: Pick<WritableOptions, "decodeStrings" | "highWaterMark" | "objectMode" | "signal">,
|
|
738
778
|
): Writable;
|
|
739
779
|
/**
|
|
740
780
|
* A utility method for creating a web `WritableStream` from a `Writable`.
|
|
741
781
|
* @since v17.0.0
|
|
742
782
|
*/
|
|
743
|
-
static toWeb(streamWritable:
|
|
783
|
+
static toWeb(streamWritable: NodeJS.WritableStream): web.WritableStream;
|
|
744
784
|
/**
|
|
745
785
|
* Is `true` if it is safe to call `writable.write()`, which means
|
|
746
786
|
* the stream has not been destroyed, errored, or ended.
|
|
747
787
|
* @since v11.4.0
|
|
748
788
|
*/
|
|
749
|
-
|
|
789
|
+
writable: boolean;
|
|
750
790
|
/**
|
|
751
791
|
* Returns whether the stream was destroyed or errored before emitting `'finish'`.
|
|
752
792
|
* @since v18.0.0, v16.17.0
|
|
@@ -806,13 +846,12 @@ declare module "node:stream" {
|
|
|
806
846
|
* @since v15.2.0, v14.17.0
|
|
807
847
|
*/
|
|
808
848
|
readonly writableNeedDrain: boolean;
|
|
809
|
-
constructor(opts?: WritableOptions);
|
|
810
849
|
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
811
850
|
_writev?(
|
|
812
|
-
chunks:
|
|
851
|
+
chunks: {
|
|
813
852
|
chunk: any;
|
|
814
853
|
encoding: BufferEncoding;
|
|
815
|
-
}
|
|
854
|
+
}[],
|
|
816
855
|
callback: (error?: Error | null) => void,
|
|
817
856
|
): void;
|
|
818
857
|
_construct?(callback: (error?: Error | null) => void): void;
|
|
@@ -974,64 +1013,56 @@ declare module "node:stream" {
|
|
|
974
1013
|
*/
|
|
975
1014
|
destroy(error?: Error): this;
|
|
976
1015
|
/**
|
|
977
|
-
*
|
|
978
|
-
*
|
|
979
|
-
*
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
addListener(
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
on(
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1028
|
-
removeListener(event: "close", listener: () => void): this;
|
|
1029
|
-
removeListener(event: "drain", listener: () => void): this;
|
|
1030
|
-
removeListener(event: "error", listener: (err: Error) => void): this;
|
|
1031
|
-
removeListener(event: "finish", listener: () => void): this;
|
|
1032
|
-
removeListener(event: "pipe", listener: (src: Readable) => void): this;
|
|
1033
|
-
removeListener(event: "unpipe", listener: (src: Readable) => void): this;
|
|
1034
|
-
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1016
|
+
* Calls `writable.destroy()` with an `AbortError` and returns
|
|
1017
|
+
* a promise that fulfills when the stream is finished.
|
|
1018
|
+
* @since v22.4.0, v20.16.0
|
|
1019
|
+
*/
|
|
1020
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
1021
|
+
// #region InternalEventEmitter
|
|
1022
|
+
addListener<E extends keyof WritableEventMap>(
|
|
1023
|
+
eventName: E,
|
|
1024
|
+
listener: (...args: WritableEventMap[E]) => void,
|
|
1025
|
+
): this;
|
|
1026
|
+
addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1027
|
+
emit<E extends keyof WritableEventMap>(eventName: E, ...args: WritableEventMap[E]): boolean;
|
|
1028
|
+
emit(eventName: string | symbol, ...args: any[]): boolean;
|
|
1029
|
+
listenerCount<E extends keyof WritableEventMap>(
|
|
1030
|
+
eventName: E,
|
|
1031
|
+
listener?: (...args: WritableEventMap[E]) => void,
|
|
1032
|
+
): number;
|
|
1033
|
+
listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number;
|
|
1034
|
+
listeners<E extends keyof WritableEventMap>(eventName: E): ((...args: WritableEventMap[E]) => void)[];
|
|
1035
|
+
listeners(eventName: string | symbol): ((...args: any[]) => void)[];
|
|
1036
|
+
off<E extends keyof WritableEventMap>(eventName: E, listener: (...args: WritableEventMap[E]) => void): this;
|
|
1037
|
+
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1038
|
+
on<E extends keyof WritableEventMap>(eventName: E, listener: (...args: WritableEventMap[E]) => void): this;
|
|
1039
|
+
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1040
|
+
once<E extends keyof WritableEventMap>(
|
|
1041
|
+
eventName: E,
|
|
1042
|
+
listener: (...args: WritableEventMap[E]) => void,
|
|
1043
|
+
): this;
|
|
1044
|
+
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1045
|
+
prependListener<E extends keyof WritableEventMap>(
|
|
1046
|
+
eventName: E,
|
|
1047
|
+
listener: (...args: WritableEventMap[E]) => void,
|
|
1048
|
+
): this;
|
|
1049
|
+
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1050
|
+
prependOnceListener<E extends keyof WritableEventMap>(
|
|
1051
|
+
eventName: E,
|
|
1052
|
+
listener: (...args: WritableEventMap[E]) => void,
|
|
1053
|
+
): this;
|
|
1054
|
+
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1055
|
+
rawListeners<E extends keyof WritableEventMap>(eventName: E): ((...args: WritableEventMap[E]) => void)[];
|
|
1056
|
+
rawListeners(eventName: string | symbol): ((...args: any[]) => void)[];
|
|
1057
|
+
// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
|
1058
|
+
removeAllListeners<E extends keyof WritableEventMap>(eventName?: E): this;
|
|
1059
|
+
removeAllListeners(eventName?: string | symbol): this;
|
|
1060
|
+
removeListener<E extends keyof WritableEventMap>(
|
|
1061
|
+
eventName: E,
|
|
1062
|
+
listener: (...args: WritableEventMap[E]) => void,
|
|
1063
|
+
): this;
|
|
1064
|
+
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1065
|
+
// #endregion
|
|
1035
1066
|
}
|
|
1036
1067
|
interface DuplexOptions<T extends Duplex = Duplex> extends ReadableOptions<T>, WritableOptions<T> {
|
|
1037
1068
|
allowHalfOpen?: boolean | undefined;
|
|
@@ -1041,6 +1072,7 @@ declare module "node:stream" {
|
|
|
1041
1072
|
writableHighWaterMark?: number | undefined;
|
|
1042
1073
|
writableCorked?: number | undefined;
|
|
1043
1074
|
}
|
|
1075
|
+
interface DuplexEventMap extends ReadableEventMap, WritableEventMap {}
|
|
1044
1076
|
/**
|
|
1045
1077
|
* Duplex streams are streams that implement both the `Readable` and `Writable` interfaces.
|
|
1046
1078
|
*
|
|
@@ -1052,17 +1084,7 @@ declare module "node:stream" {
|
|
|
1052
1084
|
* @since v0.9.4
|
|
1053
1085
|
*/
|
|
1054
1086
|
class Duplex extends Stream implements NodeJS.ReadWriteStream {
|
|
1055
|
-
|
|
1056
|
-
* If `false` then the stream will automatically end the writable side when the
|
|
1057
|
-
* readable side ends. Set initially by the `allowHalfOpen` constructor option,
|
|
1058
|
-
* which defaults to `true`.
|
|
1059
|
-
*
|
|
1060
|
-
* This can be changed manually to change the half-open behavior of an existing
|
|
1061
|
-
* `Duplex` stream instance, but must be changed before the `'end'` event is emitted.
|
|
1062
|
-
* @since v0.9.4
|
|
1063
|
-
*/
|
|
1064
|
-
allowHalfOpen: boolean;
|
|
1065
|
-
constructor(opts?: DuplexOptions);
|
|
1087
|
+
constructor(options?: DuplexOptions);
|
|
1066
1088
|
/**
|
|
1067
1089
|
* A utility method for creating duplex streams.
|
|
1068
1090
|
*
|
|
@@ -1086,137 +1108,87 @@ declare module "node:stream" {
|
|
|
1086
1108
|
*/
|
|
1087
1109
|
static from(
|
|
1088
1110
|
src:
|
|
1089
|
-
|
|
|
1090
|
-
|
|
|
1091
|
-
|
|
|
1111
|
+
| NodeJS.ReadableStream
|
|
1112
|
+
| NodeJS.WritableStream
|
|
1113
|
+
| Blob
|
|
1092
1114
|
| string
|
|
1093
1115
|
| Iterable<any>
|
|
1094
1116
|
| AsyncIterable<any>
|
|
1095
|
-
|
|
|
1117
|
+
| ((source: AsyncIterable<any>) => AsyncIterable<any>)
|
|
1118
|
+
| ((source: AsyncIterable<any>) => Promise<void>)
|
|
1096
1119
|
| Promise<any>
|
|
1097
|
-
|
|
|
1120
|
+
| web.ReadableWritablePair
|
|
1121
|
+
| web.ReadableStream
|
|
1122
|
+
| web.WritableStream,
|
|
1098
1123
|
): Duplex;
|
|
1099
1124
|
/**
|
|
1100
1125
|
* A utility method for creating a web `ReadableStream` and `WritableStream` from a `Duplex`.
|
|
1101
1126
|
* @since v17.0.0
|
|
1102
1127
|
*/
|
|
1103
|
-
static toWeb(streamDuplex:
|
|
1104
|
-
readable: streamWeb.ReadableStream;
|
|
1105
|
-
writable: streamWeb.WritableStream;
|
|
1106
|
-
};
|
|
1128
|
+
static toWeb(streamDuplex: NodeJS.ReadWriteStream): web.ReadableWritablePair;
|
|
1107
1129
|
/**
|
|
1108
1130
|
* A utility method for creating a `Duplex` from a web `ReadableStream` and `WritableStream`.
|
|
1109
1131
|
* @since v17.0.0
|
|
1110
1132
|
*/
|
|
1111
1133
|
static fromWeb(
|
|
1112
|
-
duplexStream:
|
|
1113
|
-
readable: streamWeb.ReadableStream;
|
|
1114
|
-
writable: streamWeb.WritableStream;
|
|
1115
|
-
},
|
|
1134
|
+
duplexStream: web.ReadableWritablePair,
|
|
1116
1135
|
options?: Pick<
|
|
1117
1136
|
DuplexOptions,
|
|
1118
1137
|
"allowHalfOpen" | "decodeStrings" | "encoding" | "highWaterMark" | "objectMode" | "signal"
|
|
1119
1138
|
>,
|
|
1120
1139
|
): Duplex;
|
|
1121
1140
|
/**
|
|
1122
|
-
*
|
|
1123
|
-
*
|
|
1124
|
-
*
|
|
1125
|
-
*
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1128
|
-
*
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
addListener(
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
once(event: "data", listener: (chunk: any) => void): this;
|
|
1174
|
-
once(event: "drain", listener: () => void): this;
|
|
1175
|
-
once(event: "end", listener: () => void): this;
|
|
1176
|
-
once(event: "error", listener: (err: Error) => void): this;
|
|
1177
|
-
once(event: "finish", listener: () => void): this;
|
|
1178
|
-
once(event: "pause", listener: () => void): this;
|
|
1179
|
-
once(event: "pipe", listener: (src: Readable) => void): this;
|
|
1180
|
-
once(event: "readable", listener: () => void): this;
|
|
1181
|
-
once(event: "resume", listener: () => void): this;
|
|
1182
|
-
once(event: "unpipe", listener: (src: Readable) => void): this;
|
|
1183
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1184
|
-
prependListener(event: "close", listener: () => void): this;
|
|
1185
|
-
prependListener(event: "data", listener: (chunk: any) => void): this;
|
|
1186
|
-
prependListener(event: "drain", listener: () => void): this;
|
|
1187
|
-
prependListener(event: "end", listener: () => void): this;
|
|
1188
|
-
prependListener(event: "error", listener: (err: Error) => void): this;
|
|
1189
|
-
prependListener(event: "finish", listener: () => void): this;
|
|
1190
|
-
prependListener(event: "pause", listener: () => void): this;
|
|
1191
|
-
prependListener(event: "pipe", listener: (src: Readable) => void): this;
|
|
1192
|
-
prependListener(event: "readable", listener: () => void): this;
|
|
1193
|
-
prependListener(event: "resume", listener: () => void): this;
|
|
1194
|
-
prependListener(event: "unpipe", listener: (src: Readable) => void): this;
|
|
1195
|
-
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1196
|
-
prependOnceListener(event: "close", listener: () => void): this;
|
|
1197
|
-
prependOnceListener(event: "data", listener: (chunk: any) => void): this;
|
|
1198
|
-
prependOnceListener(event: "drain", listener: () => void): this;
|
|
1199
|
-
prependOnceListener(event: "end", listener: () => void): this;
|
|
1200
|
-
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
|
1201
|
-
prependOnceListener(event: "finish", listener: () => void): this;
|
|
1202
|
-
prependOnceListener(event: "pause", listener: () => void): this;
|
|
1203
|
-
prependOnceListener(event: "pipe", listener: (src: Readable) => void): this;
|
|
1204
|
-
prependOnceListener(event: "readable", listener: () => void): this;
|
|
1205
|
-
prependOnceListener(event: "resume", listener: () => void): this;
|
|
1206
|
-
prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this;
|
|
1207
|
-
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1208
|
-
removeListener(event: "close", listener: () => void): this;
|
|
1209
|
-
removeListener(event: "data", listener: (chunk: any) => void): this;
|
|
1210
|
-
removeListener(event: "drain", listener: () => void): this;
|
|
1211
|
-
removeListener(event: "end", listener: () => void): this;
|
|
1212
|
-
removeListener(event: "error", listener: (err: Error) => void): this;
|
|
1213
|
-
removeListener(event: "finish", listener: () => void): this;
|
|
1214
|
-
removeListener(event: "pause", listener: () => void): this;
|
|
1215
|
-
removeListener(event: "pipe", listener: (src: Readable) => void): this;
|
|
1216
|
-
removeListener(event: "readable", listener: () => void): this;
|
|
1217
|
-
removeListener(event: "resume", listener: () => void): this;
|
|
1218
|
-
removeListener(event: "unpipe", listener: (src: Readable) => void): this;
|
|
1219
|
-
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1141
|
+
* If `false` then the stream will automatically end the writable side when the
|
|
1142
|
+
* readable side ends. Set initially by the `allowHalfOpen` constructor option,
|
|
1143
|
+
* which defaults to `true`.
|
|
1144
|
+
*
|
|
1145
|
+
* This can be changed manually to change the half-open behavior of an existing
|
|
1146
|
+
* `Duplex` stream instance, but must be changed before the `'end'` event is emitted.
|
|
1147
|
+
* @since v0.9.4
|
|
1148
|
+
*/
|
|
1149
|
+
allowHalfOpen: boolean;
|
|
1150
|
+
// #region InternalEventEmitter
|
|
1151
|
+
addListener<E extends keyof DuplexEventMap>(
|
|
1152
|
+
eventName: E,
|
|
1153
|
+
listener: (...args: DuplexEventMap[E]) => void,
|
|
1154
|
+
): this;
|
|
1155
|
+
addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1156
|
+
emit<E extends keyof DuplexEventMap>(eventName: E, ...args: DuplexEventMap[E]): boolean;
|
|
1157
|
+
emit(eventName: string | symbol, ...args: any[]): boolean;
|
|
1158
|
+
listenerCount<E extends keyof DuplexEventMap>(
|
|
1159
|
+
eventName: E,
|
|
1160
|
+
listener?: (...args: DuplexEventMap[E]) => void,
|
|
1161
|
+
): number;
|
|
1162
|
+
listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number;
|
|
1163
|
+
listeners<E extends keyof DuplexEventMap>(eventName: E): ((...args: DuplexEventMap[E]) => void)[];
|
|
1164
|
+
listeners(eventName: string | symbol): ((...args: any[]) => void)[];
|
|
1165
|
+
off<E extends keyof DuplexEventMap>(eventName: E, listener: (...args: DuplexEventMap[E]) => void): this;
|
|
1166
|
+
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1167
|
+
on<E extends keyof DuplexEventMap>(eventName: E, listener: (...args: DuplexEventMap[E]) => void): this;
|
|
1168
|
+
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1169
|
+
once<E extends keyof DuplexEventMap>(eventName: E, listener: (...args: DuplexEventMap[E]) => void): this;
|
|
1170
|
+
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1171
|
+
prependListener<E extends keyof DuplexEventMap>(
|
|
1172
|
+
eventName: E,
|
|
1173
|
+
listener: (...args: DuplexEventMap[E]) => void,
|
|
1174
|
+
): this;
|
|
1175
|
+
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1176
|
+
prependOnceListener<E extends keyof DuplexEventMap>(
|
|
1177
|
+
eventName: E,
|
|
1178
|
+
listener: (...args: DuplexEventMap[E]) => void,
|
|
1179
|
+
): this;
|
|
1180
|
+
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1181
|
+
rawListeners<E extends keyof DuplexEventMap>(eventName: E): ((...args: DuplexEventMap[E]) => void)[];
|
|
1182
|
+
rawListeners(eventName: string | symbol): ((...args: any[]) => void)[];
|
|
1183
|
+
// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
|
1184
|
+
removeAllListeners<E extends keyof DuplexEventMap>(eventName?: E): this;
|
|
1185
|
+
removeAllListeners(eventName?: string | symbol): this;
|
|
1186
|
+
removeListener<E extends keyof DuplexEventMap>(
|
|
1187
|
+
eventName: E,
|
|
1188
|
+
listener: (...args: DuplexEventMap[E]) => void,
|
|
1189
|
+
): this;
|
|
1190
|
+
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
1191
|
+
// #endregion
|
|
1220
1192
|
}
|
|
1221
1193
|
interface Duplex extends Readable, Writable {}
|
|
1222
1194
|
/**
|
|
@@ -1240,8 +1212,10 @@ declare module "node:stream" {
|
|
|
1240
1212
|
function duplexPair(options?: DuplexOptions): [Duplex, Duplex];
|
|
1241
1213
|
type TransformCallback = (error?: Error | null, data?: any) => void;
|
|
1242
1214
|
interface TransformOptions<T extends Transform = Transform> extends DuplexOptions<T> {
|
|
1243
|
-
transform
|
|
1244
|
-
|
|
1215
|
+
transform?:
|
|
1216
|
+
| ((this: T, chunk: any, encoding: BufferEncoding, callback: TransformCallback) => void)
|
|
1217
|
+
| undefined;
|
|
1218
|
+
flush?: ((this: T, callback: TransformCallback) => void) | undefined;
|
|
1245
1219
|
}
|
|
1246
1220
|
/**
|
|
1247
1221
|
* Transform streams are `Duplex` streams where the output is in some way
|
|
@@ -1255,7 +1229,7 @@ declare module "node:stream" {
|
|
|
1255
1229
|
* @since v0.9.4
|
|
1256
1230
|
*/
|
|
1257
1231
|
class Transform extends Duplex {
|
|
1258
|
-
constructor(
|
|
1232
|
+
constructor(options?: TransformOptions);
|
|
1259
1233
|
_transform(chunk: any, encoding: BufferEncoding, callback: TransformCallback): void;
|
|
1260
1234
|
_flush(callback: TransformCallback): void;
|
|
1261
1235
|
}
|
|
@@ -1343,7 +1317,9 @@ declare module "node:stream" {
|
|
|
1343
1317
|
* @param signal A signal representing possible cancellation
|
|
1344
1318
|
* @param stream A stream to attach a signal to.
|
|
1345
1319
|
*/
|
|
1346
|
-
function addAbortSignal<
|
|
1320
|
+
function addAbortSignal<
|
|
1321
|
+
T extends NodeJS.ReadableStream | NodeJS.WritableStream | web.ReadableStream | web.WritableStream,
|
|
1322
|
+
>(signal: AbortSignal, stream: T): T;
|
|
1347
1323
|
/**
|
|
1348
1324
|
* Returns the default highWaterMark used by streams.
|
|
1349
1325
|
* Defaults to `65536` (64 KiB), or `16` for `objectMode`.
|
|
@@ -1387,7 +1363,7 @@ declare module "node:stream" {
|
|
|
1387
1363
|
* Especially useful in error handling scenarios where a stream is destroyed
|
|
1388
1364
|
* prematurely (like an aborted HTTP request), and will not emit `'end'` or `'finish'`.
|
|
1389
1365
|
*
|
|
1390
|
-
* The `finished` API provides [`promise version`](https://nodejs.org/docs/latest-
|
|
1366
|
+
* The `finished` API provides [`promise version`](https://nodejs.org/docs/latest-v25.x/api/stream.html#streamfinishedstream-options).
|
|
1391
1367
|
*
|
|
1392
1368
|
* `stream.finished()` leaves dangling event listeners (in particular `'error'`, `'end'`, `'finish'` and `'close'`) after `callback` has been
|
|
1393
1369
|
* invoked. The reason for this is so that unexpected `'error'` events (due to
|
|
@@ -1407,46 +1383,57 @@ declare module "node:stream" {
|
|
|
1407
1383
|
* @returns A cleanup function which removes all registered listeners.
|
|
1408
1384
|
*/
|
|
1409
1385
|
function finished(
|
|
1410
|
-
stream: NodeJS.ReadableStream | NodeJS.WritableStream |
|
|
1386
|
+
stream: NodeJS.ReadableStream | NodeJS.WritableStream | web.ReadableStream | web.WritableStream,
|
|
1411
1387
|
options: FinishedOptions,
|
|
1412
1388
|
callback: (err?: NodeJS.ErrnoException | null) => void,
|
|
1413
1389
|
): () => void;
|
|
1414
1390
|
function finished(
|
|
1415
|
-
stream: NodeJS.ReadableStream | NodeJS.WritableStream |
|
|
1391
|
+
stream: NodeJS.ReadableStream | NodeJS.WritableStream | web.ReadableStream | web.WritableStream,
|
|
1416
1392
|
callback: (err?: NodeJS.ErrnoException | null) => void,
|
|
1417
1393
|
): () => void;
|
|
1418
1394
|
namespace finished {
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
options?: FinishedOptions,
|
|
1422
|
-
): Promise<void>;
|
|
1395
|
+
import __promisify__ = promises.finished;
|
|
1396
|
+
export { __promisify__ };
|
|
1423
1397
|
}
|
|
1424
|
-
type PipelineSourceFunction<
|
|
1425
|
-
type PipelineSource<
|
|
1426
|
-
|
|
1398
|
+
type PipelineSourceFunction<O> = (options?: Abortable) => Iterable<O> | AsyncIterable<O>;
|
|
1399
|
+
type PipelineSource<O> =
|
|
1400
|
+
| NodeJS.ReadableStream
|
|
1401
|
+
| web.ReadableStream<O>
|
|
1402
|
+
| web.TransformStream<any, O>
|
|
1403
|
+
| Iterable<O>
|
|
1404
|
+
| AsyncIterable<O>
|
|
1405
|
+
| PipelineSourceFunction<O>;
|
|
1406
|
+
type PipelineSourceArgument<T> = (T extends (...args: any[]) => infer R ? R : T) extends infer S
|
|
1407
|
+
? S extends web.TransformStream<any, infer O> ? web.ReadableStream<O> : S
|
|
1408
|
+
: never;
|
|
1409
|
+
type PipelineTransformGenerator<S extends PipelineTransformSource<any>, O> = (
|
|
1410
|
+
source: PipelineSourceArgument<S>,
|
|
1411
|
+
options?: Abortable,
|
|
1412
|
+
) => AsyncIterable<O>;
|
|
1413
|
+
type PipelineTransformStreams<I, O> =
|
|
1427
1414
|
| NodeJS.ReadWriteStream
|
|
1428
|
-
|
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
type
|
|
1434
|
-
type
|
|
1435
|
-
|
|
1436
|
-
|
|
1415
|
+
| web.TransformStream<I, O>;
|
|
1416
|
+
type PipelineTransform<S extends PipelineTransformSource<any>, O> = S extends
|
|
1417
|
+
PipelineSource<infer I> | PipelineTransformStreams<any, infer I> | ((...args: any[]) => infer I)
|
|
1418
|
+
? PipelineTransformStreams<I, O> | PipelineTransformGenerator<S, O>
|
|
1419
|
+
: never;
|
|
1420
|
+
type PipelineTransformSource<O> = PipelineSource<O> | PipelineTransform<any, O>;
|
|
1421
|
+
type PipelineDestinationFunction<S extends PipelineTransformSource<any>, R> = (
|
|
1422
|
+
source: PipelineSourceArgument<S>,
|
|
1423
|
+
options?: Abortable,
|
|
1424
|
+
) => R;
|
|
1425
|
+
type PipelineDestination<S extends PipelineTransformSource<any>, R> = S extends
|
|
1426
|
+
PipelineSource<infer I> | PipelineTransform<any, infer I> ?
|
|
1437
1427
|
| NodeJS.WritableStream
|
|
1438
|
-
|
|
|
1439
|
-
|
|
|
1428
|
+
| web.WritableStream<I>
|
|
1429
|
+
| web.TransformStream<I, any>
|
|
1430
|
+
| PipelineDestinationFunction<S, R>
|
|
1440
1431
|
: never;
|
|
1441
|
-
type PipelineCallback<S extends PipelineDestination<any, any>> =
|
|
1442
|
-
|
|
1443
|
-
: (
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
interface PipelineOptions {
|
|
1447
|
-
signal?: AbortSignal | undefined;
|
|
1448
|
-
end?: boolean | undefined;
|
|
1449
|
-
}
|
|
1432
|
+
type PipelineCallback<S extends PipelineDestination<any, any>> = (
|
|
1433
|
+
err: NodeJS.ErrnoException | null,
|
|
1434
|
+
value: S extends (...args: any[]) => PromiseLike<infer R> ? R : undefined,
|
|
1435
|
+
) => void;
|
|
1436
|
+
type PipelineResult<S extends PipelineDestination<any, any>> = S extends NodeJS.WritableStream ? S : Duplex;
|
|
1450
1437
|
/**
|
|
1451
1438
|
* A module method to pipe between streams and generators forwarding errors and
|
|
1452
1439
|
* properly cleaning up and provide a callback when the pipeline is complete.
|
|
@@ -1475,7 +1462,7 @@ declare module "node:stream" {
|
|
|
1475
1462
|
* );
|
|
1476
1463
|
* ```
|
|
1477
1464
|
*
|
|
1478
|
-
* The `pipeline` API provides a [`promise version`](https://nodejs.org/docs/latest-
|
|
1465
|
+
* The `pipeline` API provides a [`promise version`](https://nodejs.org/docs/latest-v25.x/api/stream.html#streampipelinesource-transforms-destination-options).
|
|
1479
1466
|
*
|
|
1480
1467
|
* `stream.pipeline()` will call `stream.destroy(err)` on all streams except:
|
|
1481
1468
|
*
|
|
@@ -1512,158 +1499,274 @@ declare module "node:stream" {
|
|
|
1512
1499
|
* @since v10.0.0
|
|
1513
1500
|
* @param callback Called when the pipeline is fully done.
|
|
1514
1501
|
*/
|
|
1515
|
-
function pipeline<
|
|
1516
|
-
source:
|
|
1517
|
-
destination:
|
|
1518
|
-
callback: PipelineCallback<
|
|
1519
|
-
):
|
|
1502
|
+
function pipeline<S extends PipelineSource<any>, D extends PipelineDestination<S, any>>(
|
|
1503
|
+
source: S,
|
|
1504
|
+
destination: D,
|
|
1505
|
+
callback: PipelineCallback<D>,
|
|
1506
|
+
): PipelineResult<D>;
|
|
1520
1507
|
function pipeline<
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1508
|
+
S extends PipelineSource<any>,
|
|
1509
|
+
T extends PipelineTransform<S, any>,
|
|
1510
|
+
D extends PipelineDestination<T, any>,
|
|
1524
1511
|
>(
|
|
1525
|
-
source:
|
|
1526
|
-
|
|
1527
|
-
destination:
|
|
1528
|
-
callback: PipelineCallback<
|
|
1529
|
-
):
|
|
1512
|
+
source: S,
|
|
1513
|
+
transform: T,
|
|
1514
|
+
destination: D,
|
|
1515
|
+
callback: PipelineCallback<D>,
|
|
1516
|
+
): PipelineResult<D>;
|
|
1530
1517
|
function pipeline<
|
|
1531
|
-
|
|
1532
|
-
T1 extends PipelineTransform<
|
|
1518
|
+
S extends PipelineSource<any>,
|
|
1519
|
+
T1 extends PipelineTransform<S, any>,
|
|
1533
1520
|
T2 extends PipelineTransform<T1, any>,
|
|
1534
|
-
|
|
1521
|
+
D extends PipelineDestination<T2, any>,
|
|
1535
1522
|
>(
|
|
1536
|
-
source:
|
|
1523
|
+
source: S,
|
|
1537
1524
|
transform1: T1,
|
|
1538
1525
|
transform2: T2,
|
|
1539
|
-
destination:
|
|
1540
|
-
callback: PipelineCallback<
|
|
1541
|
-
):
|
|
1526
|
+
destination: D,
|
|
1527
|
+
callback: PipelineCallback<D>,
|
|
1528
|
+
): PipelineResult<D>;
|
|
1542
1529
|
function pipeline<
|
|
1543
|
-
|
|
1544
|
-
T1 extends PipelineTransform<
|
|
1530
|
+
S extends PipelineSource<any>,
|
|
1531
|
+
T1 extends PipelineTransform<S, any>,
|
|
1545
1532
|
T2 extends PipelineTransform<T1, any>,
|
|
1546
1533
|
T3 extends PipelineTransform<T2, any>,
|
|
1547
|
-
|
|
1534
|
+
D extends PipelineDestination<T3, any>,
|
|
1548
1535
|
>(
|
|
1549
|
-
source:
|
|
1536
|
+
source: S,
|
|
1550
1537
|
transform1: T1,
|
|
1551
1538
|
transform2: T2,
|
|
1552
1539
|
transform3: T3,
|
|
1553
|
-
destination:
|
|
1554
|
-
callback: PipelineCallback<
|
|
1555
|
-
):
|
|
1540
|
+
destination: D,
|
|
1541
|
+
callback: PipelineCallback<D>,
|
|
1542
|
+
): PipelineResult<D>;
|
|
1556
1543
|
function pipeline<
|
|
1557
|
-
|
|
1558
|
-
T1 extends PipelineTransform<
|
|
1544
|
+
S extends PipelineSource<any>,
|
|
1545
|
+
T1 extends PipelineTransform<S, any>,
|
|
1559
1546
|
T2 extends PipelineTransform<T1, any>,
|
|
1560
1547
|
T3 extends PipelineTransform<T2, any>,
|
|
1561
1548
|
T4 extends PipelineTransform<T3, any>,
|
|
1562
|
-
|
|
1549
|
+
D extends PipelineDestination<T4, any>,
|
|
1563
1550
|
>(
|
|
1564
|
-
source:
|
|
1551
|
+
source: S,
|
|
1565
1552
|
transform1: T1,
|
|
1566
1553
|
transform2: T2,
|
|
1567
1554
|
transform3: T3,
|
|
1568
1555
|
transform4: T4,
|
|
1569
|
-
destination:
|
|
1570
|
-
callback: PipelineCallback<
|
|
1571
|
-
):
|
|
1556
|
+
destination: D,
|
|
1557
|
+
callback: PipelineCallback<D>,
|
|
1558
|
+
): PipelineResult<D>;
|
|
1572
1559
|
function pipeline(
|
|
1573
|
-
streams: ReadonlyArray<
|
|
1560
|
+
streams: ReadonlyArray<PipelineSource<any> | PipelineTransform<any, any> | PipelineDestination<any, any>>,
|
|
1574
1561
|
callback: (err: NodeJS.ErrnoException | null) => void,
|
|
1575
1562
|
): NodeJS.WritableStream;
|
|
1576
1563
|
function pipeline(
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
>
|
|
1564
|
+
...streams: [
|
|
1565
|
+
...[PipelineSource<any>, ...PipelineTransform<any, any>[], PipelineDestination<any, any>],
|
|
1566
|
+
callback: ((err: NodeJS.ErrnoException | null) => void),
|
|
1567
|
+
]
|
|
1582
1568
|
): NodeJS.WritableStream;
|
|
1583
1569
|
namespace pipeline {
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
destination: B,
|
|
1587
|
-
options?: PipelineOptions,
|
|
1588
|
-
): PipelinePromise<B>;
|
|
1589
|
-
function __promisify__<
|
|
1590
|
-
A extends PipelineSource<any>,
|
|
1591
|
-
T1 extends PipelineTransform<A, any>,
|
|
1592
|
-
B extends PipelineDestination<T1, any>,
|
|
1593
|
-
>(
|
|
1594
|
-
source: A,
|
|
1595
|
-
transform1: T1,
|
|
1596
|
-
destination: B,
|
|
1597
|
-
options?: PipelineOptions,
|
|
1598
|
-
): PipelinePromise<B>;
|
|
1599
|
-
function __promisify__<
|
|
1600
|
-
A extends PipelineSource<any>,
|
|
1601
|
-
T1 extends PipelineTransform<A, any>,
|
|
1602
|
-
T2 extends PipelineTransform<T1, any>,
|
|
1603
|
-
B extends PipelineDestination<T2, any>,
|
|
1604
|
-
>(
|
|
1605
|
-
source: A,
|
|
1606
|
-
transform1: T1,
|
|
1607
|
-
transform2: T2,
|
|
1608
|
-
destination: B,
|
|
1609
|
-
options?: PipelineOptions,
|
|
1610
|
-
): PipelinePromise<B>;
|
|
1611
|
-
function __promisify__<
|
|
1612
|
-
A extends PipelineSource<any>,
|
|
1613
|
-
T1 extends PipelineTransform<A, any>,
|
|
1614
|
-
T2 extends PipelineTransform<T1, any>,
|
|
1615
|
-
T3 extends PipelineTransform<T2, any>,
|
|
1616
|
-
B extends PipelineDestination<T3, any>,
|
|
1617
|
-
>(
|
|
1618
|
-
source: A,
|
|
1619
|
-
transform1: T1,
|
|
1620
|
-
transform2: T2,
|
|
1621
|
-
transform3: T3,
|
|
1622
|
-
destination: B,
|
|
1623
|
-
options?: PipelineOptions,
|
|
1624
|
-
): PipelinePromise<B>;
|
|
1625
|
-
function __promisify__<
|
|
1626
|
-
A extends PipelineSource<any>,
|
|
1627
|
-
T1 extends PipelineTransform<A, any>,
|
|
1628
|
-
T2 extends PipelineTransform<T1, any>,
|
|
1629
|
-
T3 extends PipelineTransform<T2, any>,
|
|
1630
|
-
T4 extends PipelineTransform<T3, any>,
|
|
1631
|
-
B extends PipelineDestination<T4, any>,
|
|
1632
|
-
>(
|
|
1633
|
-
source: A,
|
|
1634
|
-
transform1: T1,
|
|
1635
|
-
transform2: T2,
|
|
1636
|
-
transform3: T3,
|
|
1637
|
-
transform4: T4,
|
|
1638
|
-
destination: B,
|
|
1639
|
-
options?: PipelineOptions,
|
|
1640
|
-
): PipelinePromise<B>;
|
|
1641
|
-
function __promisify__(
|
|
1642
|
-
streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>,
|
|
1643
|
-
options?: PipelineOptions,
|
|
1644
|
-
): Promise<void>;
|
|
1645
|
-
function __promisify__(
|
|
1646
|
-
stream1: NodeJS.ReadableStream,
|
|
1647
|
-
stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
|
|
1648
|
-
...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | PipelineOptions>
|
|
1649
|
-
): Promise<void>;
|
|
1650
|
-
}
|
|
1651
|
-
interface Pipe {
|
|
1652
|
-
close(): void;
|
|
1653
|
-
hasRef(): boolean;
|
|
1654
|
-
ref(): void;
|
|
1655
|
-
unref(): void;
|
|
1570
|
+
import __promisify__ = promises.pipeline;
|
|
1571
|
+
export { __promisify__ };
|
|
1656
1572
|
}
|
|
1573
|
+
type ComposeSource<O> =
|
|
1574
|
+
| NodeJS.ReadableStream
|
|
1575
|
+
| web.ReadableStream<O>
|
|
1576
|
+
| Iterable<O>
|
|
1577
|
+
| AsyncIterable<O>
|
|
1578
|
+
| (() => AsyncIterable<O>);
|
|
1579
|
+
type ComposeTransformStreams<I, O> = NodeJS.ReadWriteStream | web.TransformStream<I, O>;
|
|
1580
|
+
type ComposeTransformGenerator<I, O> = (source: AsyncIterable<I>) => AsyncIterable<O>;
|
|
1581
|
+
type ComposeTransform<S extends ComposeTransformSource<any>, O> = S extends
|
|
1582
|
+
ComposeSource<infer I> | ComposeTransformStreams<any, infer I> | ComposeTransformGenerator<any, infer I>
|
|
1583
|
+
? ComposeTransformStreams<I, O> | ComposeTransformGenerator<I, O>
|
|
1584
|
+
: never;
|
|
1585
|
+
type ComposeTransformSource<O> = ComposeSource<O> | ComposeTransform<any, O>;
|
|
1586
|
+
type ComposeDestination<S extends ComposeTransformSource<any>> = S extends ComposeTransformSource<infer I> ?
|
|
1587
|
+
| NodeJS.WritableStream
|
|
1588
|
+
| web.WritableStream<I>
|
|
1589
|
+
| web.TransformStream<I, any>
|
|
1590
|
+
| ((source: AsyncIterable<I>) => void)
|
|
1591
|
+
: never;
|
|
1592
|
+
/**
|
|
1593
|
+
* Combines two or more streams into a `Duplex` stream that writes to the
|
|
1594
|
+
* first stream and reads from the last. Each provided stream is piped into
|
|
1595
|
+
* the next, using `stream.pipeline`. If any of the streams error then all
|
|
1596
|
+
* are destroyed, including the outer `Duplex` stream.
|
|
1597
|
+
*
|
|
1598
|
+
* Because `stream.compose` returns a new stream that in turn can (and
|
|
1599
|
+
* should) be piped into other streams, it enables composition. In contrast,
|
|
1600
|
+
* when passing streams to `stream.pipeline`, typically the first stream is
|
|
1601
|
+
* a readable stream and the last a writable stream, forming a closed
|
|
1602
|
+
* circuit.
|
|
1603
|
+
*
|
|
1604
|
+
* If passed a `Function` it must be a factory method taking a `source`
|
|
1605
|
+
* `Iterable`.
|
|
1606
|
+
*
|
|
1607
|
+
* ```js
|
|
1608
|
+
* import { compose, Transform } from 'node:stream';
|
|
1609
|
+
*
|
|
1610
|
+
* const removeSpaces = new Transform({
|
|
1611
|
+
* transform(chunk, encoding, callback) {
|
|
1612
|
+
* callback(null, String(chunk).replace(' ', ''));
|
|
1613
|
+
* },
|
|
1614
|
+
* });
|
|
1615
|
+
*
|
|
1616
|
+
* async function* toUpper(source) {
|
|
1617
|
+
* for await (const chunk of source) {
|
|
1618
|
+
* yield String(chunk).toUpperCase();
|
|
1619
|
+
* }
|
|
1620
|
+
* }
|
|
1621
|
+
*
|
|
1622
|
+
* let res = '';
|
|
1623
|
+
* for await (const buf of compose(removeSpaces, toUpper).end('hello world')) {
|
|
1624
|
+
* res += buf;
|
|
1625
|
+
* }
|
|
1626
|
+
*
|
|
1627
|
+
* console.log(res); // prints 'HELLOWORLD'
|
|
1628
|
+
* ```
|
|
1629
|
+
*
|
|
1630
|
+
* `stream.compose` can be used to convert async iterables, generators and
|
|
1631
|
+
* functions into streams.
|
|
1632
|
+
*
|
|
1633
|
+
* * `AsyncIterable` converts into a readable `Duplex`. Cannot yield
|
|
1634
|
+
* `null`.
|
|
1635
|
+
* * `AsyncGeneratorFunction` converts into a readable/writable transform `Duplex`.
|
|
1636
|
+
* Must take a source `AsyncIterable` as first parameter. Cannot yield
|
|
1637
|
+
* `null`.
|
|
1638
|
+
* * `AsyncFunction` converts into a writable `Duplex`. Must return
|
|
1639
|
+
* either `null` or `undefined`.
|
|
1640
|
+
*
|
|
1641
|
+
* ```js
|
|
1642
|
+
* import { compose } from 'node:stream';
|
|
1643
|
+
* import { finished } from 'node:stream/promises';
|
|
1644
|
+
*
|
|
1645
|
+
* // Convert AsyncIterable into readable Duplex.
|
|
1646
|
+
* const s1 = compose(async function*() {
|
|
1647
|
+
* yield 'Hello';
|
|
1648
|
+
* yield 'World';
|
|
1649
|
+
* }());
|
|
1650
|
+
*
|
|
1651
|
+
* // Convert AsyncGenerator into transform Duplex.
|
|
1652
|
+
* const s2 = compose(async function*(source) {
|
|
1653
|
+
* for await (const chunk of source) {
|
|
1654
|
+
* yield String(chunk).toUpperCase();
|
|
1655
|
+
* }
|
|
1656
|
+
* });
|
|
1657
|
+
*
|
|
1658
|
+
* let res = '';
|
|
1659
|
+
*
|
|
1660
|
+
* // Convert AsyncFunction into writable Duplex.
|
|
1661
|
+
* const s3 = compose(async function(source) {
|
|
1662
|
+
* for await (const chunk of source) {
|
|
1663
|
+
* res += chunk;
|
|
1664
|
+
* }
|
|
1665
|
+
* });
|
|
1666
|
+
*
|
|
1667
|
+
* await finished(compose(s1, s2, s3));
|
|
1668
|
+
*
|
|
1669
|
+
* console.log(res); // prints 'HELLOWORLD'
|
|
1670
|
+
* ```
|
|
1671
|
+
*
|
|
1672
|
+
* See [`readable.compose(stream)`](https://nodejs.org/docs/latest-v25.x/api/stream.html#readablecomposestream-options) for `stream.compose` as operator.
|
|
1673
|
+
* @since v16.9.0
|
|
1674
|
+
* @experimental
|
|
1675
|
+
*/
|
|
1676
|
+
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
1677
|
+
function compose(stream: ComposeSource<any> | ComposeDestination<any>): Duplex;
|
|
1678
|
+
function compose<
|
|
1679
|
+
S extends ComposeSource<any> | ComposeTransform<any, any>,
|
|
1680
|
+
D extends ComposeTransform<S, any> | ComposeDestination<S>,
|
|
1681
|
+
>(
|
|
1682
|
+
source: S,
|
|
1683
|
+
destination: D,
|
|
1684
|
+
): Duplex;
|
|
1685
|
+
function compose<
|
|
1686
|
+
S extends ComposeSource<any> | ComposeTransform<any, any>,
|
|
1687
|
+
T extends ComposeTransform<S, any>,
|
|
1688
|
+
D extends ComposeTransform<T, any> | ComposeDestination<T>,
|
|
1689
|
+
>(source: S, transform: T, destination: D): Duplex;
|
|
1690
|
+
function compose<
|
|
1691
|
+
S extends ComposeSource<any> | ComposeTransform<any, any>,
|
|
1692
|
+
T1 extends ComposeTransform<S, any>,
|
|
1693
|
+
T2 extends ComposeTransform<T1, any>,
|
|
1694
|
+
D extends ComposeTransform<T2, any> | ComposeDestination<T2>,
|
|
1695
|
+
>(source: S, transform1: T1, transform2: T2, destination: D): Duplex;
|
|
1696
|
+
function compose<
|
|
1697
|
+
S extends ComposeSource<any> | ComposeTransform<any, any>,
|
|
1698
|
+
T1 extends ComposeTransform<S, any>,
|
|
1699
|
+
T2 extends ComposeTransform<T1, any>,
|
|
1700
|
+
T3 extends ComposeTransform<T2, any>,
|
|
1701
|
+
D extends ComposeTransform<T3, any> | ComposeDestination<T3>,
|
|
1702
|
+
>(source: S, transform1: T1, transform2: T2, transform3: T3, destination: D): Duplex;
|
|
1703
|
+
function compose<
|
|
1704
|
+
S extends ComposeSource<any> | ComposeTransform<any, any>,
|
|
1705
|
+
T1 extends ComposeTransform<S, any>,
|
|
1706
|
+
T2 extends ComposeTransform<T1, any>,
|
|
1707
|
+
T3 extends ComposeTransform<T2, any>,
|
|
1708
|
+
T4 extends ComposeTransform<T3, any>,
|
|
1709
|
+
D extends ComposeTransform<T4, any> | ComposeDestination<T4>,
|
|
1710
|
+
>(source: S, transform1: T1, transform2: T2, transform3: T3, transform4: T4, destination: D): Duplex;
|
|
1711
|
+
function compose(
|
|
1712
|
+
...streams: [
|
|
1713
|
+
ComposeSource<any>,
|
|
1714
|
+
...ComposeTransform<any, any>[],
|
|
1715
|
+
ComposeDestination<any>,
|
|
1716
|
+
]
|
|
1717
|
+
): Duplex;
|
|
1718
|
+
/* eslint-enable @definitelytyped/no-unnecessary-generics */
|
|
1657
1719
|
/**
|
|
1658
1720
|
* Returns whether the stream has encountered an error.
|
|
1659
1721
|
* @since v17.3.0, v16.14.0
|
|
1660
1722
|
*/
|
|
1661
|
-
function isErrored(
|
|
1723
|
+
function isErrored(
|
|
1724
|
+
stream: NodeJS.ReadableStream | NodeJS.WritableStream | web.ReadableStream | web.WritableStream,
|
|
1725
|
+
): boolean;
|
|
1662
1726
|
/**
|
|
1663
1727
|
* Returns whether the stream is readable.
|
|
1664
1728
|
* @since v17.4.0, v16.14.0
|
|
1729
|
+
* @returns Only returns `null` if `stream` is not a valid `Readable`, `Duplex` or `ReadableStream`.
|
|
1665
1730
|
*/
|
|
1666
|
-
function isReadable(stream:
|
|
1731
|
+
function isReadable(stream: NodeJS.ReadableStream | web.ReadableStream): boolean | null;
|
|
1732
|
+
/**
|
|
1733
|
+
* Returns whether the stream is writable.
|
|
1734
|
+
* @since v20.0.0
|
|
1735
|
+
* @returns Only returns `null` if `stream` is not a valid `Writable`, `Duplex` or `WritableStream`.
|
|
1736
|
+
*/
|
|
1737
|
+
function isWritable(stream: NodeJS.WritableStream | web.WritableStream): boolean | null;
|
|
1738
|
+
}
|
|
1739
|
+
global {
|
|
1740
|
+
namespace NodeJS {
|
|
1741
|
+
// These interfaces are vestigial, and correspond roughly to the "streams2" interfaces
|
|
1742
|
+
// from early versions of Node.js, but they are still used widely across the ecosystem.
|
|
1743
|
+
// Accordingly, they are commonly used as "in-types" for @types/node APIs, so that
|
|
1744
|
+
// eg. streams returned from older libraries will still be considered valid input to
|
|
1745
|
+
// functions which accept stream arguments.
|
|
1746
|
+
// It's not possible to change or remove these without astronomical levels of breakage.
|
|
1747
|
+
interface ReadableStream extends EventEmitter {
|
|
1748
|
+
readable: boolean;
|
|
1749
|
+
read(size?: number): string | Buffer;
|
|
1750
|
+
setEncoding(encoding: BufferEncoding): this;
|
|
1751
|
+
pause(): this;
|
|
1752
|
+
resume(): this;
|
|
1753
|
+
isPaused(): boolean;
|
|
1754
|
+
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean | undefined }): T;
|
|
1755
|
+
unpipe(destination?: WritableStream): this;
|
|
1756
|
+
unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
|
|
1757
|
+
wrap(oldStream: ReadableStream): this;
|
|
1758
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
|
|
1759
|
+
}
|
|
1760
|
+
interface WritableStream extends EventEmitter {
|
|
1761
|
+
writable: boolean;
|
|
1762
|
+
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
|
|
1763
|
+
write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
|
|
1764
|
+
end(cb?: () => void): this;
|
|
1765
|
+
end(data: string | Uint8Array, cb?: () => void): this;
|
|
1766
|
+
end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
|
|
1767
|
+
}
|
|
1768
|
+
interface ReadWriteStream extends ReadableStream, WritableStream {}
|
|
1769
|
+
}
|
|
1667
1770
|
}
|
|
1668
1771
|
export = Stream;
|
|
1669
1772
|
}
|