@idlebox/stripe-node-types 24.0.14-patch.0 → 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 +113 -1
- package/assert.d.ts +162 -248
- package/async_hooks.d.ts +20 -5
- package/buffer.buffer.d.ts +24 -6
- package/buffer.d.ts +63 -168
- package/child_process.d.ts +117 -223
- package/cluster.d.ts +251 -329
- package/compatibility/iterators.d.ts +15 -0
- package/console.d.ts +60 -346
- package/constants.d.ts +15 -1
- package/crypto.d.ts +713 -1149
- package/dgram.d.ts +30 -50
- package/diagnostics_channel.d.ts +16 -3
- package/dns/promises.d.ts +15 -0
- package/dns.d.ts +150 -131
- package/domain.d.ts +25 -14
- package/events.d.ts +858 -719
- package/fs/promises.d.ts +117 -53
- package/fs.d.ts +729 -484
- package/globals.d.ts +142 -344
- package/globals.typedarray.d.ts +94 -0
- package/http.d.ts +358 -246
- package/http2.d.ts +578 -711
- package/https.d.ts +85 -216
- package/index.d.ts +39 -3
- package/inspector/promises.d.ts +54 -0
- package/inspector.d.ts +180 -3936
- package/inspector.generated.d.ts +4242 -0
- package/module.d.ts +60 -95
- package/my-shim.d.ts +15 -0
- package/net.d.ts +102 -186
- package/os.d.ts +32 -6
- package/package.json +3 -8
- package/path/posix.d.ts +20 -0
- package/path/win32.d.ts +20 -0
- package/path.d.ts +132 -122
- package/perf_hooks.d.ts +310 -644
- package/process.d.ts +192 -138
- package/punycode.d.ts +17 -2
- package/querystring.d.ts +16 -1
- package/quic.d.ts +926 -0
- package/readline/promises.d.ts +16 -1
- package/readline.d.ts +80 -118
- package/repl.d.ts +98 -96
- package/sea.d.ts +25 -1
- package/sqlite.d.ts +277 -13
- package/stream/consumers.d.ts +22 -7
- package/stream/promises.d.ts +148 -12
- package/stream/web.d.ts +187 -494
- package/stream.d.ts +608 -490
- package/string_decoder.d.ts +18 -3
- package/test/reporters.d.ts +112 -0
- package/test.d.ts +238 -199
- package/timers/promises.d.ts +16 -1
- package/timers.d.ts +16 -129
- package/tls.d.ts +163 -163
- package/trace_events.d.ts +21 -6
- package/ts5.6/buffer.buffer.d.ts +25 -8
- package/ts5.6/compatibility/float16array.d.ts +15 -0
- package/ts5.6/globals.typedarray.d.ts +31 -0
- package/ts5.6/index.d.ts +39 -3
- package/ts5.7/compatibility/float16array.d.ts +15 -0
- package/ts5.7/index.d.ts +39 -3
- package/tty.d.ts +70 -13
- package/undici-types/agent.d.ts +20 -4
- package/undici-types/api.d.ts +15 -0
- package/undici-types/balanced-pool.d.ts +15 -0
- package/undici-types/cache-interceptor.d.ts +15 -0
- package/undici-types/cache.d.ts +15 -0
- package/undici-types/client-stats.d.ts +31 -0
- package/undici-types/client.d.ts +21 -5
- package/undici-types/connector.d.ts +15 -0
- package/undici-types/content-type.d.ts +15 -0
- package/undici-types/cookies.d.ts +15 -0
- package/undici-types/diagnostics-channel.d.ts +24 -1
- package/undici-types/dispatcher.d.ts +18 -8
- package/undici-types/env-http-proxy-agent.d.ts +17 -1
- package/undici-types/errors.d.ts +20 -15
- package/undici-types/eventsource.d.ts +24 -4
- package/undici-types/fetch.d.ts +16 -0
- package/undici-types/formdata.d.ts +15 -0
- package/undici-types/global-dispatcher.d.ts +15 -0
- package/undici-types/global-origin.d.ts +15 -0
- package/undici-types/h2c-client.d.ts +15 -2
- package/undici-types/handlers.d.ts +16 -1
- package/undici-types/header.d.ts +15 -0
- package/undici-types/index.d.ts +21 -1
- package/undici-types/interceptors.d.ts +20 -0
- package/undici-types/mock-agent.d.ts +18 -0
- package/undici-types/mock-call-history.d.ts +15 -0
- package/undici-types/mock-client.d.ts +17 -0
- package/undici-types/mock-errors.d.ts +15 -0
- package/undici-types/mock-interceptor.d.ts +17 -1
- package/undici-types/mock-pool.d.ts +17 -0
- package/undici-types/package.json +1 -1
- package/undici-types/patch.d.ts +15 -0
- package/undici-types/pool-stats.d.ts +15 -0
- package/undici-types/pool.d.ts +17 -0
- package/undici-types/proxy-agent.d.ts +16 -0
- package/undici-types/readable.d.ts +15 -0
- package/undici-types/retry-agent.d.ts +15 -0
- package/undici-types/retry-handler.d.ts +24 -0
- package/undici-types/snapshot-agent.d.ts +125 -0
- package/undici-types/util.d.ts +15 -0
- package/undici-types/utility.d.ts +15 -0
- package/undici-types/webidl.d.ts +126 -36
- package/undici-types/websocket.d.ts +18 -1
- package/url.d.ts +107 -587
- package/util/types.d.ts +571 -0
- package/util.d.ts +158 -792
- package/v8.d.ts +82 -7
- package/vm.d.ts +267 -108
- package/wasi.d.ts +38 -2
- package/web-globals/abortcontroller.d.ts +75 -0
- package/web-globals/blob.d.ts +39 -0
- package/web-globals/console.d.ts +25 -0
- 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} +72 -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 +306 -349
- package/zlib.d.ts +59 -94
- package/ts5.1/compatibility/disposable.d.ts +0 -13
- package/ts5.1/index.d.ts +0 -100
package/stream.d.ts
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
|
+
// biome-ignore-all lint: generated file
|
|
2
|
+
// biome-ignore-all assist: generated file
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
|
|
6
|
+
/******************************************************************************
|
|
7
|
+
* GENERATED FILE, DO NOT MODIFY
|
|
8
|
+
* 这是生成的文件,千万不要修改
|
|
9
|
+
*
|
|
10
|
+
* @build-script/codegen - The Simple Code Generater
|
|
11
|
+
* https://github.com/GongT/baobao
|
|
12
|
+
*
|
|
13
|
+
******************************************************************************/
|
|
14
|
+
|
|
15
|
+
|
|
1
16
|
/**
|
|
2
17
|
* A stream is an abstract interface for working with streaming data in Node.js.
|
|
3
18
|
* The `node:stream` module provides an API for implementing the stream interface.
|
|
4
19
|
*
|
|
5
|
-
* There are many stream objects provided by Node.js. For instance, a [request to an HTTP server](https://nodejs.org/docs/latest-
|
|
6
|
-
* 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.
|
|
7
22
|
*
|
|
8
|
-
* 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).
|
|
9
24
|
*
|
|
10
25
|
* To access the `node:stream` module:
|
|
11
26
|
*
|
|
@@ -15,58 +30,88 @@
|
|
|
15
30
|
*
|
|
16
31
|
* The `node:stream` module is useful for creating new types of stream instances.
|
|
17
32
|
* It is usually not necessary to use the `node:stream` module to consume streams.
|
|
18
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
33
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/stream.js)
|
|
19
34
|
*/
|
|
20
35
|
|
|
21
36
|
declare module "node:stream" {
|
|
37
|
+
import { Blob } from 'node:buffer';
|
|
22
38
|
import { Abortable, EventEmitter } from 'node:events';
|
|
23
|
-
import
|
|
24
|
-
import * as
|
|
25
|
-
import * as streamWeb from 'node:stream/web';
|
|
26
|
-
|
|
27
|
-
type ComposeFnParam = (source: any) => void;
|
|
28
|
-
|
|
39
|
+
import * as promises from 'node:stream/promises';
|
|
40
|
+
import * as web from 'node:stream/web';
|
|
29
41
|
class Stream extends EventEmitter {
|
|
42
|
+
/**
|
|
43
|
+
* @since v0.9.4
|
|
44
|
+
*/
|
|
30
45
|
pipe<T extends NodeJS.WritableStream>(
|
|
31
46
|
destination: T,
|
|
32
|
-
options?:
|
|
33
|
-
end?: boolean | undefined;
|
|
34
|
-
},
|
|
35
|
-
): T;
|
|
36
|
-
compose<T extends NodeJS.ReadableStream>(
|
|
37
|
-
stream: T | ComposeFnParam | Iterable<T> | AsyncIterable<T>,
|
|
38
|
-
options?: { signal: AbortSignal },
|
|
47
|
+
options?: Stream.PipeOptions,
|
|
39
48
|
): T;
|
|
40
49
|
}
|
|
41
50
|
namespace Stream {
|
|
42
|
-
export {
|
|
51
|
+
export { promises, Stream };
|
|
43
52
|
}
|
|
44
53
|
namespace Stream {
|
|
54
|
+
interface PipeOptions {
|
|
55
|
+
/**
|
|
56
|
+
* End the writer when the reader ends.
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
end?: boolean | undefined;
|
|
60
|
+
}
|
|
45
61
|
interface StreamOptions<T extends Stream> extends Abortable {
|
|
46
62
|
emitClose?: boolean | undefined;
|
|
47
63
|
highWaterMark?: number | undefined;
|
|
48
64
|
objectMode?: boolean | undefined;
|
|
49
|
-
construct
|
|
50
|
-
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;
|
|
51
67
|
autoDestroy?: boolean | undefined;
|
|
52
68
|
}
|
|
53
69
|
interface ReadableOptions<T extends Readable = Readable> extends StreamOptions<T> {
|
|
54
70
|
encoding?: BufferEncoding | undefined;
|
|
55
|
-
read
|
|
71
|
+
read?: ((this: T, size: number) => void) | undefined;
|
|
56
72
|
}
|
|
57
|
-
interface
|
|
73
|
+
interface ReadableIteratorOptions {
|
|
58
74
|
/**
|
|
59
|
-
*
|
|
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.
|
|
60
86
|
* @default 1
|
|
61
87
|
*/
|
|
62
|
-
concurrency?: number;
|
|
63
|
-
/**
|
|
64
|
-
|
|
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": [];
|
|
65
109
|
}
|
|
66
110
|
/**
|
|
67
111
|
* @since v0.9.4
|
|
68
112
|
*/
|
|
69
113
|
class Readable extends Stream implements NodeJS.ReadableStream {
|
|
114
|
+
constructor(options?: ReadableOptions);
|
|
70
115
|
/**
|
|
71
116
|
* A utility method for creating Readable Streams out of iterators.
|
|
72
117
|
* @since v12.3.0, v10.17.0
|
|
@@ -79,7 +124,7 @@ declare module "node:stream" {
|
|
|
79
124
|
* @since v17.0.0
|
|
80
125
|
*/
|
|
81
126
|
static fromWeb(
|
|
82
|
-
readableStream:
|
|
127
|
+
readableStream: web.ReadableStream,
|
|
83
128
|
options?: Pick<ReadableOptions, "encoding" | "highWaterMark" | "objectMode" | "signal">,
|
|
84
129
|
): Readable;
|
|
85
130
|
/**
|
|
@@ -87,16 +132,14 @@ declare module "node:stream" {
|
|
|
87
132
|
* @since v17.0.0
|
|
88
133
|
*/
|
|
89
134
|
static toWeb(
|
|
90
|
-
streamReadable:
|
|
91
|
-
options?:
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
): streamWeb.ReadableStream;
|
|
135
|
+
streamReadable: NodeJS.ReadableStream,
|
|
136
|
+
options?: ReadableToWebOptions,
|
|
137
|
+
): web.ReadableStream;
|
|
95
138
|
/**
|
|
96
139
|
* Returns whether the stream has been read from or cancelled.
|
|
97
140
|
* @since v16.8.0
|
|
98
141
|
*/
|
|
99
|
-
static isDisturbed(stream:
|
|
142
|
+
static isDisturbed(stream: NodeJS.ReadableStream | web.ReadableStream): boolean;
|
|
100
143
|
/**
|
|
101
144
|
* Returns whether the stream was destroyed or errored before emitting `'end'`.
|
|
102
145
|
* @since v16.8.0
|
|
@@ -119,16 +162,16 @@ declare module "node:stream" {
|
|
|
119
162
|
*/
|
|
120
163
|
readonly readableEncoding: BufferEncoding | null;
|
|
121
164
|
/**
|
|
122
|
-
* 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.
|
|
123
166
|
* @since v12.9.0
|
|
124
167
|
*/
|
|
125
168
|
readonly readableEnded: boolean;
|
|
126
169
|
/**
|
|
127
170
|
* This property reflects the current state of a `Readable` stream as described
|
|
128
|
-
* 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.
|
|
129
172
|
* @since v9.4.0
|
|
130
173
|
*/
|
|
131
|
-
|
|
174
|
+
readableFlowing: boolean | null;
|
|
132
175
|
/**
|
|
133
176
|
* Returns the value of `highWaterMark` passed when creating this `Readable`.
|
|
134
177
|
* @since v9.3.0
|
|
@@ -161,7 +204,6 @@ declare module "node:stream" {
|
|
|
161
204
|
* @since v18.0.0
|
|
162
205
|
*/
|
|
163
206
|
readonly errored: Error | null;
|
|
164
|
-
constructor(opts?: ReadableOptions);
|
|
165
207
|
_construct?(callback: (error?: Error | null) => void): void;
|
|
166
208
|
_read(size: number): void;
|
|
167
209
|
/**
|
|
@@ -445,16 +487,41 @@ declare module "node:stream" {
|
|
|
445
487
|
*/
|
|
446
488
|
wrap(stream: NodeJS.ReadableStream): this;
|
|
447
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;
|
|
448
518
|
/**
|
|
449
519
|
* The iterator created by this method gives users the option to cancel the destruction
|
|
450
520
|
* of the stream if the `for await...of` loop is exited by `return`, `break`, or `throw`,
|
|
451
521
|
* or if the iterator should destroy the stream if the stream emitted an error during iteration.
|
|
452
522
|
* @since v16.3.0
|
|
453
|
-
* @param options.destroyOnReturn When set to `false`, calling `return` on the async iterator,
|
|
454
|
-
* or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream.
|
|
455
|
-
* **Default: `true`**.
|
|
456
523
|
*/
|
|
457
|
-
iterator(options?:
|
|
524
|
+
iterator(options?: ReadableIteratorOptions): NodeJS.AsyncIterator<any>;
|
|
458
525
|
/**
|
|
459
526
|
* This method allows mapping over the stream. The *fn* function will be called for every chunk in the stream.
|
|
460
527
|
* If the *fn* function returns a promise - that promise will be `await`ed before being passed to the result stream.
|
|
@@ -462,7 +529,7 @@ declare module "node:stream" {
|
|
|
462
529
|
* @param fn a function to map over every chunk in the stream. Async or not.
|
|
463
530
|
* @returns a stream mapped with the function *fn*.
|
|
464
531
|
*/
|
|
465
|
-
map(fn: (data: any, options?:
|
|
532
|
+
map(fn: (data: any, options?: Abortable) => any, options?: ReadableOperatorOptions): Readable;
|
|
466
533
|
/**
|
|
467
534
|
* This method allows filtering the stream. For each chunk in the stream the *fn* function will be called
|
|
468
535
|
* and if it returns a truthy value, the chunk will be passed to the result stream.
|
|
@@ -472,8 +539,8 @@ declare module "node:stream" {
|
|
|
472
539
|
* @returns a stream filtered with the predicate *fn*.
|
|
473
540
|
*/
|
|
474
541
|
filter(
|
|
475
|
-
fn: (data: any, options?:
|
|
476
|
-
options?:
|
|
542
|
+
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
543
|
+
options?: ReadableOperatorOptions,
|
|
477
544
|
): Readable;
|
|
478
545
|
/**
|
|
479
546
|
* This method allows iterating a stream. For each chunk in the stream the *fn* function will be called.
|
|
@@ -491,8 +558,8 @@ declare module "node:stream" {
|
|
|
491
558
|
* @returns a promise for when the stream has finished.
|
|
492
559
|
*/
|
|
493
560
|
forEach(
|
|
494
|
-
fn: (data: any, options?:
|
|
495
|
-
options?:
|
|
561
|
+
fn: (data: any, options?: Abortable) => void | Promise<void>,
|
|
562
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
496
563
|
): Promise<void>;
|
|
497
564
|
/**
|
|
498
565
|
* This method allows easily obtaining the contents of a stream.
|
|
@@ -502,7 +569,7 @@ declare module "node:stream" {
|
|
|
502
569
|
* @since v17.5.0
|
|
503
570
|
* @returns a promise containing an array with the contents of the stream.
|
|
504
571
|
*/
|
|
505
|
-
toArray(options?:
|
|
572
|
+
toArray(options?: Abortable): Promise<any[]>;
|
|
506
573
|
/**
|
|
507
574
|
* This method is similar to `Array.prototype.some` and calls *fn* on each chunk in the stream
|
|
508
575
|
* until the awaited return value is `true` (or any truthy value). Once an *fn* call on a chunk
|
|
@@ -513,8 +580,8 @@ declare module "node:stream" {
|
|
|
513
580
|
* @returns a promise evaluating to `true` if *fn* returned a truthy value for at least one of the chunks.
|
|
514
581
|
*/
|
|
515
582
|
some(
|
|
516
|
-
fn: (data: any, options?:
|
|
517
|
-
options?:
|
|
583
|
+
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
584
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
518
585
|
): Promise<boolean>;
|
|
519
586
|
/**
|
|
520
587
|
* This method is similar to `Array.prototype.find` and calls *fn* on each chunk in the stream
|
|
@@ -527,12 +594,12 @@ declare module "node:stream" {
|
|
|
527
594
|
* or `undefined` if no element was found.
|
|
528
595
|
*/
|
|
529
596
|
find<T>(
|
|
530
|
-
fn: (data: any, options?:
|
|
531
|
-
options?:
|
|
597
|
+
fn: (data: any, options?: Abortable) => data is T,
|
|
598
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
532
599
|
): Promise<T | undefined>;
|
|
533
600
|
find(
|
|
534
|
-
fn: (data: any, options?:
|
|
535
|
-
options?:
|
|
601
|
+
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
602
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
536
603
|
): Promise<any>;
|
|
537
604
|
/**
|
|
538
605
|
* This method is similar to `Array.prototype.every` and calls *fn* on each chunk in the stream
|
|
@@ -544,8 +611,8 @@ declare module "node:stream" {
|
|
|
544
611
|
* @returns a promise evaluating to `true` if *fn* returned a truthy value for every one of the chunks.
|
|
545
612
|
*/
|
|
546
613
|
every(
|
|
547
|
-
fn: (data: any, options?:
|
|
548
|
-
options?:
|
|
614
|
+
fn: (data: any, options?: Abortable) => boolean | Promise<boolean>,
|
|
615
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
549
616
|
): Promise<boolean>;
|
|
550
617
|
/**
|
|
551
618
|
* This method returns a new stream by applying the given callback to each chunk of the stream
|
|
@@ -557,28 +624,24 @@ declare module "node:stream" {
|
|
|
557
624
|
* @param fn a function to map over every chunk in the stream. May be async. May be a stream or generator.
|
|
558
625
|
* @returns a stream flat-mapped with the function *fn*.
|
|
559
626
|
*/
|
|
560
|
-
flatMap(
|
|
627
|
+
flatMap(
|
|
628
|
+
fn: (data: any, options?: Abortable) => any,
|
|
629
|
+
options?: Pick<ReadableOperatorOptions, "concurrency" | "signal">,
|
|
630
|
+
): Readable;
|
|
561
631
|
/**
|
|
562
632
|
* This method returns a new stream with the first *limit* chunks dropped from the start.
|
|
563
633
|
* @since v17.5.0
|
|
564
634
|
* @param limit the number of chunks to drop from the readable.
|
|
565
635
|
* @returns a stream with *limit* chunks dropped from the start.
|
|
566
636
|
*/
|
|
567
|
-
drop(limit: number, options?:
|
|
637
|
+
drop(limit: number, options?: Abortable): Readable;
|
|
568
638
|
/**
|
|
569
639
|
* This method returns a new stream with the first *limit* chunks.
|
|
570
640
|
* @since v17.5.0
|
|
571
641
|
* @param limit the number of chunks to take from the readable.
|
|
572
642
|
* @returns a stream with *limit* chunks taken.
|
|
573
643
|
*/
|
|
574
|
-
take(limit: number, options?:
|
|
575
|
-
/**
|
|
576
|
-
* This method returns a new stream with chunks of the underlying stream paired with a counter
|
|
577
|
-
* in the form `[index, chunk]`. The first index value is `0` and it increases by 1 for each chunk produced.
|
|
578
|
-
* @since v17.5.0
|
|
579
|
-
* @returns a stream of indexed pairs.
|
|
580
|
-
*/
|
|
581
|
-
asIndexedPairs(options?: Pick<ArrayOptions, "signal">): Readable;
|
|
644
|
+
take(limit: number, options?: Abortable): Readable;
|
|
582
645
|
/**
|
|
583
646
|
* This method calls *fn* on each chunk of the stream in order, passing it the result from the calculation
|
|
584
647
|
* on the previous element. It returns a promise for the final value of the reduction.
|
|
@@ -593,15 +656,11 @@ declare module "node:stream" {
|
|
|
593
656
|
* @param initial the initial value to use in the reduction.
|
|
594
657
|
* @returns a promise for the final value of the reduction.
|
|
595
658
|
*/
|
|
596
|
-
reduce<T
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
options?: Pick<ArrayOptions, "signal">,
|
|
600
|
-
): Promise<T>;
|
|
601
|
-
reduce<T = any>(
|
|
602
|
-
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,
|
|
603
662
|
initial: T,
|
|
604
|
-
options?:
|
|
663
|
+
options?: Abortable,
|
|
605
664
|
): Promise<T>;
|
|
606
665
|
_destroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
|
607
666
|
/**
|
|
@@ -617,121 +676,117 @@ declare module "node:stream" {
|
|
|
617
676
|
*/
|
|
618
677
|
destroy(error?: Error): this;
|
|
619
678
|
/**
|
|
620
|
-
*
|
|
621
|
-
*
|
|
622
|
-
|
|
623
|
-
* 2. data
|
|
624
|
-
* 3. end
|
|
625
|
-
* 4. error
|
|
626
|
-
* 5. pause
|
|
627
|
-
* 6. readable
|
|
628
|
-
* 7. resume
|
|
629
|
-
*/
|
|
630
|
-
addListener(event: "close", listener: () => void): this;
|
|
631
|
-
addListener(event: "data", listener: (chunk: any) => void): this;
|
|
632
|
-
addListener(event: "end", listener: () => void): this;
|
|
633
|
-
addListener(event: "error", listener: (err: Error) => void): this;
|
|
634
|
-
addListener(event: "pause", listener: () => void): this;
|
|
635
|
-
addListener(event: "readable", listener: () => void): this;
|
|
636
|
-
addListener(event: "resume", listener: () => void): this;
|
|
637
|
-
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
638
|
-
emit(event: "close"): boolean;
|
|
639
|
-
emit(event: "data", chunk: any): boolean;
|
|
640
|
-
emit(event: "end"): boolean;
|
|
641
|
-
emit(event: "error", err: Error): boolean;
|
|
642
|
-
emit(event: "pause"): boolean;
|
|
643
|
-
emit(event: "readable"): boolean;
|
|
644
|
-
emit(event: "resume"): boolean;
|
|
645
|
-
emit(event: string | symbol, ...args: any[]): boolean;
|
|
646
|
-
on(event: "close", listener: () => void): this;
|
|
647
|
-
on(event: "data", listener: (chunk: any) => void): this;
|
|
648
|
-
on(event: "end", listener: () => void): this;
|
|
649
|
-
on(event: "error", listener: (err: Error) => void): this;
|
|
650
|
-
on(event: "pause", listener: () => void): this;
|
|
651
|
-
on(event: "readable", listener: () => void): this;
|
|
652
|
-
on(event: "resume", listener: () => void): this;
|
|
653
|
-
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
654
|
-
once(event: "close", listener: () => void): this;
|
|
655
|
-
once(event: "data", listener: (chunk: any) => void): this;
|
|
656
|
-
once(event: "end", listener: () => void): this;
|
|
657
|
-
once(event: "error", listener: (err: Error) => void): this;
|
|
658
|
-
once(event: "pause", listener: () => void): this;
|
|
659
|
-
once(event: "readable", listener: () => void): this;
|
|
660
|
-
once(event: "resume", listener: () => void): this;
|
|
661
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
662
|
-
prependListener(event: "close", listener: () => void): this;
|
|
663
|
-
prependListener(event: "data", listener: (chunk: any) => void): this;
|
|
664
|
-
prependListener(event: "end", listener: () => void): this;
|
|
665
|
-
prependListener(event: "error", listener: (err: Error) => void): this;
|
|
666
|
-
prependListener(event: "pause", listener: () => void): this;
|
|
667
|
-
prependListener(event: "readable", listener: () => void): this;
|
|
668
|
-
prependListener(event: "resume", listener: () => void): this;
|
|
669
|
-
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
670
|
-
prependOnceListener(event: "close", listener: () => void): this;
|
|
671
|
-
prependOnceListener(event: "data", listener: (chunk: any) => void): this;
|
|
672
|
-
prependOnceListener(event: "end", listener: () => void): this;
|
|
673
|
-
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
|
674
|
-
prependOnceListener(event: "pause", listener: () => void): this;
|
|
675
|
-
prependOnceListener(event: "readable", listener: () => void): this;
|
|
676
|
-
prependOnceListener(event: "resume", listener: () => void): this;
|
|
677
|
-
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
678
|
-
removeListener(event: "close", listener: () => void): this;
|
|
679
|
-
removeListener(event: "data", listener: (chunk: any) => void): this;
|
|
680
|
-
removeListener(event: "end", listener: () => void): this;
|
|
681
|
-
removeListener(event: "error", listener: (err: Error) => void): this;
|
|
682
|
-
removeListener(event: "pause", listener: () => void): this;
|
|
683
|
-
removeListener(event: "readable", listener: () => void): this;
|
|
684
|
-
removeListener(event: "resume", listener: () => void): this;
|
|
685
|
-
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
679
|
+
* @returns `AsyncIterator` to fully consume the stream.
|
|
680
|
+
* @since v10.0.0
|
|
681
|
+
*/
|
|
686
682
|
[Symbol.asyncIterator](): NodeJS.AsyncIterator<any>;
|
|
687
683
|
/**
|
|
688
|
-
* 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.
|
|
689
686
|
* @since v20.4.0
|
|
690
687
|
*/
|
|
691
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
|
|
692
734
|
}
|
|
693
735
|
interface WritableOptions<T extends Writable = Writable> extends StreamOptions<T> {
|
|
694
736
|
decodeStrings?: boolean | undefined;
|
|
695
737
|
defaultEncoding?: BufferEncoding | undefined;
|
|
696
|
-
write
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
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];
|
|
711
765
|
}
|
|
712
766
|
/**
|
|
713
767
|
* @since v0.9.4
|
|
714
768
|
*/
|
|
715
769
|
class Writable extends Stream implements NodeJS.WritableStream {
|
|
770
|
+
constructor(options?: WritableOptions);
|
|
716
771
|
/**
|
|
717
772
|
* A utility method for creating a `Writable` from a web `WritableStream`.
|
|
718
773
|
* @since v17.0.0
|
|
719
774
|
*/
|
|
720
775
|
static fromWeb(
|
|
721
|
-
writableStream:
|
|
776
|
+
writableStream: web.WritableStream,
|
|
722
777
|
options?: Pick<WritableOptions, "decodeStrings" | "highWaterMark" | "objectMode" | "signal">,
|
|
723
778
|
): Writable;
|
|
724
779
|
/**
|
|
725
780
|
* A utility method for creating a web `WritableStream` from a `Writable`.
|
|
726
781
|
* @since v17.0.0
|
|
727
782
|
*/
|
|
728
|
-
static toWeb(streamWritable:
|
|
783
|
+
static toWeb(streamWritable: NodeJS.WritableStream): web.WritableStream;
|
|
729
784
|
/**
|
|
730
785
|
* Is `true` if it is safe to call `writable.write()`, which means
|
|
731
786
|
* the stream has not been destroyed, errored, or ended.
|
|
732
787
|
* @since v11.4.0
|
|
733
788
|
*/
|
|
734
|
-
|
|
789
|
+
writable: boolean;
|
|
735
790
|
/**
|
|
736
791
|
* Returns whether the stream was destroyed or errored before emitting `'finish'`.
|
|
737
792
|
* @since v18.0.0, v16.17.0
|
|
@@ -791,13 +846,12 @@ declare module "node:stream" {
|
|
|
791
846
|
* @since v15.2.0, v14.17.0
|
|
792
847
|
*/
|
|
793
848
|
readonly writableNeedDrain: boolean;
|
|
794
|
-
constructor(opts?: WritableOptions);
|
|
795
849
|
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
796
850
|
_writev?(
|
|
797
|
-
chunks:
|
|
851
|
+
chunks: {
|
|
798
852
|
chunk: any;
|
|
799
853
|
encoding: BufferEncoding;
|
|
800
|
-
}
|
|
854
|
+
}[],
|
|
801
855
|
callback: (error?: Error | null) => void,
|
|
802
856
|
): void;
|
|
803
857
|
_construct?(callback: (error?: Error | null) => void): void;
|
|
@@ -959,64 +1013,56 @@ declare module "node:stream" {
|
|
|
959
1013
|
*/
|
|
960
1014
|
destroy(error?: Error): this;
|
|
961
1015
|
/**
|
|
962
|
-
*
|
|
963
|
-
*
|
|
964
|
-
*
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
addListener(
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
on(
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1013
|
-
removeListener(event: "close", listener: () => void): this;
|
|
1014
|
-
removeListener(event: "drain", listener: () => void): this;
|
|
1015
|
-
removeListener(event: "error", listener: (err: Error) => void): this;
|
|
1016
|
-
removeListener(event: "finish", listener: () => void): this;
|
|
1017
|
-
removeListener(event: "pipe", listener: (src: Readable) => void): this;
|
|
1018
|
-
removeListener(event: "unpipe", listener: (src: Readable) => void): this;
|
|
1019
|
-
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
|
|
1020
1066
|
}
|
|
1021
1067
|
interface DuplexOptions<T extends Duplex = Duplex> extends ReadableOptions<T>, WritableOptions<T> {
|
|
1022
1068
|
allowHalfOpen?: boolean | undefined;
|
|
@@ -1026,6 +1072,7 @@ declare module "node:stream" {
|
|
|
1026
1072
|
writableHighWaterMark?: number | undefined;
|
|
1027
1073
|
writableCorked?: number | undefined;
|
|
1028
1074
|
}
|
|
1075
|
+
interface DuplexEventMap extends ReadableEventMap, WritableEventMap {}
|
|
1029
1076
|
/**
|
|
1030
1077
|
* Duplex streams are streams that implement both the `Readable` and `Writable` interfaces.
|
|
1031
1078
|
*
|
|
@@ -1037,17 +1084,7 @@ declare module "node:stream" {
|
|
|
1037
1084
|
* @since v0.9.4
|
|
1038
1085
|
*/
|
|
1039
1086
|
class Duplex extends Stream implements NodeJS.ReadWriteStream {
|
|
1040
|
-
|
|
1041
|
-
* If `false` then the stream will automatically end the writable side when the
|
|
1042
|
-
* readable side ends. Set initially by the `allowHalfOpen` constructor option,
|
|
1043
|
-
* which defaults to `true`.
|
|
1044
|
-
*
|
|
1045
|
-
* This can be changed manually to change the half-open behavior of an existing
|
|
1046
|
-
* `Duplex` stream instance, but must be changed before the `'end'` event is emitted.
|
|
1047
|
-
* @since v0.9.4
|
|
1048
|
-
*/
|
|
1049
|
-
allowHalfOpen: boolean;
|
|
1050
|
-
constructor(opts?: DuplexOptions);
|
|
1087
|
+
constructor(options?: DuplexOptions);
|
|
1051
1088
|
/**
|
|
1052
1089
|
* A utility method for creating duplex streams.
|
|
1053
1090
|
*
|
|
@@ -1071,137 +1108,87 @@ declare module "node:stream" {
|
|
|
1071
1108
|
*/
|
|
1072
1109
|
static from(
|
|
1073
1110
|
src:
|
|
1074
|
-
|
|
|
1075
|
-
|
|
|
1076
|
-
|
|
|
1111
|
+
| NodeJS.ReadableStream
|
|
1112
|
+
| NodeJS.WritableStream
|
|
1113
|
+
| Blob
|
|
1077
1114
|
| string
|
|
1078
1115
|
| Iterable<any>
|
|
1079
1116
|
| AsyncIterable<any>
|
|
1080
|
-
|
|
|
1117
|
+
| ((source: AsyncIterable<any>) => AsyncIterable<any>)
|
|
1118
|
+
| ((source: AsyncIterable<any>) => Promise<void>)
|
|
1081
1119
|
| Promise<any>
|
|
1082
|
-
|
|
|
1120
|
+
| web.ReadableWritablePair
|
|
1121
|
+
| web.ReadableStream
|
|
1122
|
+
| web.WritableStream,
|
|
1083
1123
|
): Duplex;
|
|
1084
1124
|
/**
|
|
1085
1125
|
* A utility method for creating a web `ReadableStream` and `WritableStream` from a `Duplex`.
|
|
1086
1126
|
* @since v17.0.0
|
|
1087
1127
|
*/
|
|
1088
|
-
static toWeb(streamDuplex:
|
|
1089
|
-
readable: streamWeb.ReadableStream;
|
|
1090
|
-
writable: streamWeb.WritableStream;
|
|
1091
|
-
};
|
|
1128
|
+
static toWeb(streamDuplex: NodeJS.ReadWriteStream): web.ReadableWritablePair;
|
|
1092
1129
|
/**
|
|
1093
1130
|
* A utility method for creating a `Duplex` from a web `ReadableStream` and `WritableStream`.
|
|
1094
1131
|
* @since v17.0.0
|
|
1095
1132
|
*/
|
|
1096
1133
|
static fromWeb(
|
|
1097
|
-
duplexStream:
|
|
1098
|
-
readable: streamWeb.ReadableStream;
|
|
1099
|
-
writable: streamWeb.WritableStream;
|
|
1100
|
-
},
|
|
1134
|
+
duplexStream: web.ReadableWritablePair,
|
|
1101
1135
|
options?: Pick<
|
|
1102
1136
|
DuplexOptions,
|
|
1103
1137
|
"allowHalfOpen" | "decodeStrings" | "encoding" | "highWaterMark" | "objectMode" | "signal"
|
|
1104
1138
|
>,
|
|
1105
1139
|
): Duplex;
|
|
1106
1140
|
/**
|
|
1107
|
-
*
|
|
1108
|
-
*
|
|
1109
|
-
*
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
addListener(
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
once(event: "data", listener: (chunk: any) => void): this;
|
|
1159
|
-
once(event: "drain", listener: () => void): this;
|
|
1160
|
-
once(event: "end", listener: () => void): this;
|
|
1161
|
-
once(event: "error", listener: (err: Error) => void): this;
|
|
1162
|
-
once(event: "finish", listener: () => void): this;
|
|
1163
|
-
once(event: "pause", listener: () => void): this;
|
|
1164
|
-
once(event: "pipe", listener: (src: Readable) => void): this;
|
|
1165
|
-
once(event: "readable", listener: () => void): this;
|
|
1166
|
-
once(event: "resume", listener: () => void): this;
|
|
1167
|
-
once(event: "unpipe", listener: (src: Readable) => void): this;
|
|
1168
|
-
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1169
|
-
prependListener(event: "close", listener: () => void): this;
|
|
1170
|
-
prependListener(event: "data", listener: (chunk: any) => void): this;
|
|
1171
|
-
prependListener(event: "drain", listener: () => void): this;
|
|
1172
|
-
prependListener(event: "end", listener: () => void): this;
|
|
1173
|
-
prependListener(event: "error", listener: (err: Error) => void): this;
|
|
1174
|
-
prependListener(event: "finish", listener: () => void): this;
|
|
1175
|
-
prependListener(event: "pause", listener: () => void): this;
|
|
1176
|
-
prependListener(event: "pipe", listener: (src: Readable) => void): this;
|
|
1177
|
-
prependListener(event: "readable", listener: () => void): this;
|
|
1178
|
-
prependListener(event: "resume", listener: () => void): this;
|
|
1179
|
-
prependListener(event: "unpipe", listener: (src: Readable) => void): this;
|
|
1180
|
-
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1181
|
-
prependOnceListener(event: "close", listener: () => void): this;
|
|
1182
|
-
prependOnceListener(event: "data", listener: (chunk: any) => void): this;
|
|
1183
|
-
prependOnceListener(event: "drain", listener: () => void): this;
|
|
1184
|
-
prependOnceListener(event: "end", listener: () => void): this;
|
|
1185
|
-
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
|
1186
|
-
prependOnceListener(event: "finish", listener: () => void): this;
|
|
1187
|
-
prependOnceListener(event: "pause", listener: () => void): this;
|
|
1188
|
-
prependOnceListener(event: "pipe", listener: (src: Readable) => void): this;
|
|
1189
|
-
prependOnceListener(event: "readable", listener: () => void): this;
|
|
1190
|
-
prependOnceListener(event: "resume", listener: () => void): this;
|
|
1191
|
-
prependOnceListener(event: "unpipe", listener: (src: Readable) => void): this;
|
|
1192
|
-
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
1193
|
-
removeListener(event: "close", listener: () => void): this;
|
|
1194
|
-
removeListener(event: "data", listener: (chunk: any) => void): this;
|
|
1195
|
-
removeListener(event: "drain", listener: () => void): this;
|
|
1196
|
-
removeListener(event: "end", listener: () => void): this;
|
|
1197
|
-
removeListener(event: "error", listener: (err: Error) => void): this;
|
|
1198
|
-
removeListener(event: "finish", listener: () => void): this;
|
|
1199
|
-
removeListener(event: "pause", listener: () => void): this;
|
|
1200
|
-
removeListener(event: "pipe", listener: (src: Readable) => void): this;
|
|
1201
|
-
removeListener(event: "readable", listener: () => void): this;
|
|
1202
|
-
removeListener(event: "resume", listener: () => void): this;
|
|
1203
|
-
removeListener(event: "unpipe", listener: (src: Readable) => void): this;
|
|
1204
|
-
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
|
|
1205
1192
|
}
|
|
1206
1193
|
interface Duplex extends Readable, Writable {}
|
|
1207
1194
|
/**
|
|
@@ -1225,8 +1212,10 @@ declare module "node:stream" {
|
|
|
1225
1212
|
function duplexPair(options?: DuplexOptions): [Duplex, Duplex];
|
|
1226
1213
|
type TransformCallback = (error?: Error | null, data?: any) => void;
|
|
1227
1214
|
interface TransformOptions<T extends Transform = Transform> extends DuplexOptions<T> {
|
|
1228
|
-
transform
|
|
1229
|
-
|
|
1215
|
+
transform?:
|
|
1216
|
+
| ((this: T, chunk: any, encoding: BufferEncoding, callback: TransformCallback) => void)
|
|
1217
|
+
| undefined;
|
|
1218
|
+
flush?: ((this: T, callback: TransformCallback) => void) | undefined;
|
|
1230
1219
|
}
|
|
1231
1220
|
/**
|
|
1232
1221
|
* Transform streams are `Duplex` streams where the output is in some way
|
|
@@ -1240,7 +1229,7 @@ declare module "node:stream" {
|
|
|
1240
1229
|
* @since v0.9.4
|
|
1241
1230
|
*/
|
|
1242
1231
|
class Transform extends Duplex {
|
|
1243
|
-
constructor(
|
|
1232
|
+
constructor(options?: TransformOptions);
|
|
1244
1233
|
_transform(chunk: any, encoding: BufferEncoding, callback: TransformCallback): void;
|
|
1245
1234
|
_flush(callback: TransformCallback): void;
|
|
1246
1235
|
}
|
|
@@ -1328,7 +1317,9 @@ declare module "node:stream" {
|
|
|
1328
1317
|
* @param signal A signal representing possible cancellation
|
|
1329
1318
|
* @param stream A stream to attach a signal to.
|
|
1330
1319
|
*/
|
|
1331
|
-
function addAbortSignal<
|
|
1320
|
+
function addAbortSignal<
|
|
1321
|
+
T extends NodeJS.ReadableStream | NodeJS.WritableStream | web.ReadableStream | web.WritableStream,
|
|
1322
|
+
>(signal: AbortSignal, stream: T): T;
|
|
1332
1323
|
/**
|
|
1333
1324
|
* Returns the default highWaterMark used by streams.
|
|
1334
1325
|
* Defaults to `65536` (64 KiB), or `16` for `objectMode`.
|
|
@@ -1372,7 +1363,7 @@ declare module "node:stream" {
|
|
|
1372
1363
|
* Especially useful in error handling scenarios where a stream is destroyed
|
|
1373
1364
|
* prematurely (like an aborted HTTP request), and will not emit `'end'` or `'finish'`.
|
|
1374
1365
|
*
|
|
1375
|
-
* 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).
|
|
1376
1367
|
*
|
|
1377
1368
|
* `stream.finished()` leaves dangling event listeners (in particular `'error'`, `'end'`, `'finish'` and `'close'`) after `callback` has been
|
|
1378
1369
|
* invoked. The reason for this is so that unexpected `'error'` events (due to
|
|
@@ -1392,46 +1383,57 @@ declare module "node:stream" {
|
|
|
1392
1383
|
* @returns A cleanup function which removes all registered listeners.
|
|
1393
1384
|
*/
|
|
1394
1385
|
function finished(
|
|
1395
|
-
stream: NodeJS.ReadableStream | NodeJS.WritableStream |
|
|
1386
|
+
stream: NodeJS.ReadableStream | NodeJS.WritableStream | web.ReadableStream | web.WritableStream,
|
|
1396
1387
|
options: FinishedOptions,
|
|
1397
1388
|
callback: (err?: NodeJS.ErrnoException | null) => void,
|
|
1398
1389
|
): () => void;
|
|
1399
1390
|
function finished(
|
|
1400
|
-
stream: NodeJS.ReadableStream | NodeJS.WritableStream |
|
|
1391
|
+
stream: NodeJS.ReadableStream | NodeJS.WritableStream | web.ReadableStream | web.WritableStream,
|
|
1401
1392
|
callback: (err?: NodeJS.ErrnoException | null) => void,
|
|
1402
1393
|
): () => void;
|
|
1403
1394
|
namespace finished {
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
options?: FinishedOptions,
|
|
1407
|
-
): Promise<void>;
|
|
1395
|
+
import __promisify__ = promises.finished;
|
|
1396
|
+
export { __promisify__ };
|
|
1408
1397
|
}
|
|
1409
|
-
type PipelineSourceFunction<
|
|
1410
|
-
type PipelineSource<
|
|
1411
|
-
|
|
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> =
|
|
1412
1414
|
| NodeJS.ReadWriteStream
|
|
1413
|
-
|
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
type
|
|
1419
|
-
type
|
|
1420
|
-
|
|
1421
|
-
|
|
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> ?
|
|
1422
1427
|
| NodeJS.WritableStream
|
|
1423
|
-
|
|
|
1424
|
-
|
|
|
1428
|
+
| web.WritableStream<I>
|
|
1429
|
+
| web.TransformStream<I, any>
|
|
1430
|
+
| PipelineDestinationFunction<S, R>
|
|
1425
1431
|
: never;
|
|
1426
|
-
type PipelineCallback<S extends PipelineDestination<any, any>> =
|
|
1427
|
-
|
|
1428
|
-
: (
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
interface PipelineOptions {
|
|
1432
|
-
signal?: AbortSignal | undefined;
|
|
1433
|
-
end?: boolean | undefined;
|
|
1434
|
-
}
|
|
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;
|
|
1435
1437
|
/**
|
|
1436
1438
|
* A module method to pipe between streams and generators forwarding errors and
|
|
1437
1439
|
* properly cleaning up and provide a callback when the pipeline is complete.
|
|
@@ -1460,7 +1462,7 @@ declare module "node:stream" {
|
|
|
1460
1462
|
* );
|
|
1461
1463
|
* ```
|
|
1462
1464
|
*
|
|
1463
|
-
* 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).
|
|
1464
1466
|
*
|
|
1465
1467
|
* `stream.pipeline()` will call `stream.destroy(err)` on all streams except:
|
|
1466
1468
|
*
|
|
@@ -1497,158 +1499,274 @@ declare module "node:stream" {
|
|
|
1497
1499
|
* @since v10.0.0
|
|
1498
1500
|
* @param callback Called when the pipeline is fully done.
|
|
1499
1501
|
*/
|
|
1500
|
-
function pipeline<
|
|
1501
|
-
source:
|
|
1502
|
-
destination:
|
|
1503
|
-
callback: PipelineCallback<
|
|
1504
|
-
):
|
|
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>;
|
|
1505
1507
|
function pipeline<
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1508
|
+
S extends PipelineSource<any>,
|
|
1509
|
+
T extends PipelineTransform<S, any>,
|
|
1510
|
+
D extends PipelineDestination<T, any>,
|
|
1509
1511
|
>(
|
|
1510
|
-
source:
|
|
1511
|
-
|
|
1512
|
-
destination:
|
|
1513
|
-
callback: PipelineCallback<
|
|
1514
|
-
):
|
|
1512
|
+
source: S,
|
|
1513
|
+
transform: T,
|
|
1514
|
+
destination: D,
|
|
1515
|
+
callback: PipelineCallback<D>,
|
|
1516
|
+
): PipelineResult<D>;
|
|
1515
1517
|
function pipeline<
|
|
1516
|
-
|
|
1517
|
-
T1 extends PipelineTransform<
|
|
1518
|
+
S extends PipelineSource<any>,
|
|
1519
|
+
T1 extends PipelineTransform<S, any>,
|
|
1518
1520
|
T2 extends PipelineTransform<T1, any>,
|
|
1519
|
-
|
|
1521
|
+
D extends PipelineDestination<T2, any>,
|
|
1520
1522
|
>(
|
|
1521
|
-
source:
|
|
1523
|
+
source: S,
|
|
1522
1524
|
transform1: T1,
|
|
1523
1525
|
transform2: T2,
|
|
1524
|
-
destination:
|
|
1525
|
-
callback: PipelineCallback<
|
|
1526
|
-
):
|
|
1526
|
+
destination: D,
|
|
1527
|
+
callback: PipelineCallback<D>,
|
|
1528
|
+
): PipelineResult<D>;
|
|
1527
1529
|
function pipeline<
|
|
1528
|
-
|
|
1529
|
-
T1 extends PipelineTransform<
|
|
1530
|
+
S extends PipelineSource<any>,
|
|
1531
|
+
T1 extends PipelineTransform<S, any>,
|
|
1530
1532
|
T2 extends PipelineTransform<T1, any>,
|
|
1531
1533
|
T3 extends PipelineTransform<T2, any>,
|
|
1532
|
-
|
|
1534
|
+
D extends PipelineDestination<T3, any>,
|
|
1533
1535
|
>(
|
|
1534
|
-
source:
|
|
1536
|
+
source: S,
|
|
1535
1537
|
transform1: T1,
|
|
1536
1538
|
transform2: T2,
|
|
1537
1539
|
transform3: T3,
|
|
1538
|
-
destination:
|
|
1539
|
-
callback: PipelineCallback<
|
|
1540
|
-
):
|
|
1540
|
+
destination: D,
|
|
1541
|
+
callback: PipelineCallback<D>,
|
|
1542
|
+
): PipelineResult<D>;
|
|
1541
1543
|
function pipeline<
|
|
1542
|
-
|
|
1543
|
-
T1 extends PipelineTransform<
|
|
1544
|
+
S extends PipelineSource<any>,
|
|
1545
|
+
T1 extends PipelineTransform<S, any>,
|
|
1544
1546
|
T2 extends PipelineTransform<T1, any>,
|
|
1545
1547
|
T3 extends PipelineTransform<T2, any>,
|
|
1546
1548
|
T4 extends PipelineTransform<T3, any>,
|
|
1547
|
-
|
|
1549
|
+
D extends PipelineDestination<T4, any>,
|
|
1548
1550
|
>(
|
|
1549
|
-
source:
|
|
1551
|
+
source: S,
|
|
1550
1552
|
transform1: T1,
|
|
1551
1553
|
transform2: T2,
|
|
1552
1554
|
transform3: T3,
|
|
1553
1555
|
transform4: T4,
|
|
1554
|
-
destination:
|
|
1555
|
-
callback: PipelineCallback<
|
|
1556
|
-
):
|
|
1556
|
+
destination: D,
|
|
1557
|
+
callback: PipelineCallback<D>,
|
|
1558
|
+
): PipelineResult<D>;
|
|
1557
1559
|
function pipeline(
|
|
1558
|
-
streams: ReadonlyArray<
|
|
1560
|
+
streams: ReadonlyArray<PipelineSource<any> | PipelineTransform<any, any> | PipelineDestination<any, any>>,
|
|
1559
1561
|
callback: (err: NodeJS.ErrnoException | null) => void,
|
|
1560
1562
|
): NodeJS.WritableStream;
|
|
1561
1563
|
function pipeline(
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
>
|
|
1564
|
+
...streams: [
|
|
1565
|
+
...[PipelineSource<any>, ...PipelineTransform<any, any>[], PipelineDestination<any, any>],
|
|
1566
|
+
callback: ((err: NodeJS.ErrnoException | null) => void),
|
|
1567
|
+
]
|
|
1567
1568
|
): NodeJS.WritableStream;
|
|
1568
1569
|
namespace pipeline {
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
destination: B,
|
|
1572
|
-
options?: PipelineOptions,
|
|
1573
|
-
): PipelinePromise<B>;
|
|
1574
|
-
function __promisify__<
|
|
1575
|
-
A extends PipelineSource<any>,
|
|
1576
|
-
T1 extends PipelineTransform<A, any>,
|
|
1577
|
-
B extends PipelineDestination<T1, any>,
|
|
1578
|
-
>(
|
|
1579
|
-
source: A,
|
|
1580
|
-
transform1: T1,
|
|
1581
|
-
destination: B,
|
|
1582
|
-
options?: PipelineOptions,
|
|
1583
|
-
): PipelinePromise<B>;
|
|
1584
|
-
function __promisify__<
|
|
1585
|
-
A extends PipelineSource<any>,
|
|
1586
|
-
T1 extends PipelineTransform<A, any>,
|
|
1587
|
-
T2 extends PipelineTransform<T1, any>,
|
|
1588
|
-
B extends PipelineDestination<T2, any>,
|
|
1589
|
-
>(
|
|
1590
|
-
source: A,
|
|
1591
|
-
transform1: T1,
|
|
1592
|
-
transform2: T2,
|
|
1593
|
-
destination: B,
|
|
1594
|
-
options?: PipelineOptions,
|
|
1595
|
-
): PipelinePromise<B>;
|
|
1596
|
-
function __promisify__<
|
|
1597
|
-
A extends PipelineSource<any>,
|
|
1598
|
-
T1 extends PipelineTransform<A, any>,
|
|
1599
|
-
T2 extends PipelineTransform<T1, any>,
|
|
1600
|
-
T3 extends PipelineTransform<T2, any>,
|
|
1601
|
-
B extends PipelineDestination<T3, any>,
|
|
1602
|
-
>(
|
|
1603
|
-
source: A,
|
|
1604
|
-
transform1: T1,
|
|
1605
|
-
transform2: T2,
|
|
1606
|
-
transform3: T3,
|
|
1607
|
-
destination: B,
|
|
1608
|
-
options?: PipelineOptions,
|
|
1609
|
-
): PipelinePromise<B>;
|
|
1610
|
-
function __promisify__<
|
|
1611
|
-
A extends PipelineSource<any>,
|
|
1612
|
-
T1 extends PipelineTransform<A, any>,
|
|
1613
|
-
T2 extends PipelineTransform<T1, any>,
|
|
1614
|
-
T3 extends PipelineTransform<T2, any>,
|
|
1615
|
-
T4 extends PipelineTransform<T3, any>,
|
|
1616
|
-
B extends PipelineDestination<T4, any>,
|
|
1617
|
-
>(
|
|
1618
|
-
source: A,
|
|
1619
|
-
transform1: T1,
|
|
1620
|
-
transform2: T2,
|
|
1621
|
-
transform3: T3,
|
|
1622
|
-
transform4: T4,
|
|
1623
|
-
destination: B,
|
|
1624
|
-
options?: PipelineOptions,
|
|
1625
|
-
): PipelinePromise<B>;
|
|
1626
|
-
function __promisify__(
|
|
1627
|
-
streams: ReadonlyArray<NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream>,
|
|
1628
|
-
options?: PipelineOptions,
|
|
1629
|
-
): Promise<void>;
|
|
1630
|
-
function __promisify__(
|
|
1631
|
-
stream1: NodeJS.ReadableStream,
|
|
1632
|
-
stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream,
|
|
1633
|
-
...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | PipelineOptions>
|
|
1634
|
-
): Promise<void>;
|
|
1635
|
-
}
|
|
1636
|
-
interface Pipe {
|
|
1637
|
-
close(): void;
|
|
1638
|
-
hasRef(): boolean;
|
|
1639
|
-
ref(): void;
|
|
1640
|
-
unref(): void;
|
|
1570
|
+
import __promisify__ = promises.pipeline;
|
|
1571
|
+
export { __promisify__ };
|
|
1641
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 */
|
|
1642
1719
|
/**
|
|
1643
1720
|
* Returns whether the stream has encountered an error.
|
|
1644
1721
|
* @since v17.3.0, v16.14.0
|
|
1645
1722
|
*/
|
|
1646
|
-
function isErrored(
|
|
1723
|
+
function isErrored(
|
|
1724
|
+
stream: NodeJS.ReadableStream | NodeJS.WritableStream | web.ReadableStream | web.WritableStream,
|
|
1725
|
+
): boolean;
|
|
1647
1726
|
/**
|
|
1648
1727
|
* Returns whether the stream is readable.
|
|
1649
1728
|
* @since v17.4.0, v16.14.0
|
|
1729
|
+
* @returns Only returns `null` if `stream` is not a valid `Readable`, `Duplex` or `ReadableStream`.
|
|
1650
1730
|
*/
|
|
1651
|
-
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
|
+
}
|
|
1652
1770
|
}
|
|
1653
1771
|
export = Stream;
|
|
1654
1772
|
}
|