web-streams-polyfill 4.4.0 → 4.5.0
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/dist/polyfill.es5.js +2 -2
- package/dist/polyfill.js +2 -2
- package/dist/ponyfill.es5.js +2 -2
- package/dist/ponyfill.es5.mjs +2 -2
- package/dist/ponyfill.js +2 -2
- package/dist/ponyfill.mjs +2 -2
- package/package.json +37 -22
- package/types/ponyfill.d.mts +784 -0
- package/types/ponyfill.d.ts +630 -675
- package/types/tsdoc-metadata.json +0 -11
package/types/ponyfill.d.ts
CHANGED
|
@@ -1,829 +1,784 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* via its associated `AbortController` object.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* This is equivalent to the `AbortSignal` interface defined in TypeScript's DOM types or `@types/node`.
|
|
7
|
-
*
|
|
2
|
+
* {@inheritDoc QueuingStrategy.size}
|
|
8
3
|
* @public
|
|
9
4
|
*/
|
|
10
|
-
|
|
11
|
-
AbortSignal: {
|
|
12
|
-
prototype: infer T;
|
|
13
|
-
};
|
|
14
|
-
} ? T : {
|
|
15
|
-
aborted: boolean;
|
|
16
|
-
readonly reason?: any;
|
|
17
|
-
addEventListener(type: 'abort', listener: () => void): void;
|
|
18
|
-
removeEventListener(type: 'abort', listener: () => void): void;
|
|
19
|
-
};
|
|
20
|
-
|
|
5
|
+
type QueuingStrategySizeCallback<T = any> = (chunk: T) => number;
|
|
21
6
|
/**
|
|
22
|
-
* A queuing strategy that counts the number of bytes in each chunk.
|
|
23
|
-
*
|
|
24
7
|
* @public
|
|
25
8
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
get highWaterMark(): number;
|
|
32
|
-
/**
|
|
33
|
-
* Measures the size of `chunk` by returning the value of its `byteLength` property.
|
|
34
|
-
*/
|
|
35
|
-
get size(): (chunk: ArrayBufferView) => number;
|
|
9
|
+
interface QueuingStrategyInit {
|
|
10
|
+
/**
|
|
11
|
+
* {@inheritDoc QueuingStrategy.highWaterMark}
|
|
12
|
+
*/
|
|
13
|
+
highWaterMark: number;
|
|
36
14
|
}
|
|
37
|
-
|
|
38
15
|
/**
|
|
39
|
-
* A queuing strategy
|
|
16
|
+
* A queuing strategy.
|
|
40
17
|
*
|
|
41
18
|
* @public
|
|
42
19
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*/
|
|
53
|
-
get size(): (chunk: any) => 1;
|
|
20
|
+
interface QueuingStrategy<T = any> {
|
|
21
|
+
/**
|
|
22
|
+
* A non-negative number indicating the high water mark of the stream using this queuing strategy.
|
|
23
|
+
*/
|
|
24
|
+
highWaterMark?: number;
|
|
25
|
+
/**
|
|
26
|
+
* A function that computes and returns the finite non-negative size of the given chunk value.
|
|
27
|
+
*/
|
|
28
|
+
size?: QueuingStrategySizeCallback<T>;
|
|
54
29
|
}
|
|
55
|
-
|
|
56
30
|
/**
|
|
57
|
-
* A
|
|
31
|
+
* A result returned by {@link ReadableStreamDefaultReader.read}.
|
|
58
32
|
*
|
|
59
33
|
* @public
|
|
60
34
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*/
|
|
69
|
-
size?: QueuingStrategySizeCallback<T>;
|
|
70
|
-
}
|
|
71
|
-
|
|
35
|
+
type ReadableStreamDefaultReadResult<T> = {
|
|
36
|
+
done: false;
|
|
37
|
+
value: T;
|
|
38
|
+
} | {
|
|
39
|
+
done: true;
|
|
40
|
+
value: undefined;
|
|
41
|
+
};
|
|
72
42
|
/**
|
|
43
|
+
* A default reader vended by a {@link ReadableStream}.
|
|
44
|
+
*
|
|
73
45
|
* @public
|
|
74
46
|
*/
|
|
75
|
-
export declare
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
47
|
+
export declare class ReadableStreamDefaultReader<R = any> {
|
|
48
|
+
constructor(stream: ReadableStream<R>);
|
|
49
|
+
/**
|
|
50
|
+
* Returns a promise that will be fulfilled when the stream becomes closed,
|
|
51
|
+
* or rejected if the stream ever errors or the reader's lock is released before the stream finishes closing.
|
|
52
|
+
*/
|
|
53
|
+
get closed(): Promise<undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
|
|
56
|
+
*/
|
|
57
|
+
cancel(reason?: any): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Returns a promise that allows access to the next chunk from the stream's internal queue, if available.
|
|
60
|
+
*
|
|
61
|
+
* If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source.
|
|
62
|
+
*/
|
|
63
|
+
read(): Promise<ReadableStreamDefaultReadResult<R>>;
|
|
64
|
+
/**
|
|
65
|
+
* Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active.
|
|
66
|
+
* If the associated stream is errored when the lock is released, the reader will appear errored in the same way
|
|
67
|
+
* from now on; otherwise, the reader will appear closed.
|
|
68
|
+
*
|
|
69
|
+
* A reader's lock cannot be released while it still has a pending read request, i.e., if a promise returned by
|
|
70
|
+
* the reader's {@link ReadableStreamDefaultReader.read | read()} method has not yet been settled. Attempting to
|
|
71
|
+
* do so will throw a `TypeError` and leave the reader locked to the stream.
|
|
72
|
+
*/
|
|
73
|
+
releaseLock(): void;
|
|
80
74
|
}
|
|
81
|
-
|
|
82
75
|
/**
|
|
83
|
-
* {@
|
|
76
|
+
* An async iterator returned by {@link ReadableStream.values}.
|
|
77
|
+
*
|
|
84
78
|
* @public
|
|
85
79
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
interface ReadableStreamAsyncIterator<R> extends AsyncIterableIterator<R> {
|
|
81
|
+
next(): Promise<IteratorResult<R, undefined>>;
|
|
82
|
+
return(value?: any): Promise<IteratorResult<any>>;
|
|
83
|
+
}
|
|
88
84
|
/**
|
|
89
|
-
*
|
|
85
|
+
* Options for {@link ReadableStream.(getReader:2)}.
|
|
90
86
|
*
|
|
91
87
|
* @public
|
|
92
88
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Returns the current BYOB pull request, or `null` if there isn't one.
|
|
97
|
-
*/
|
|
98
|
-
get byobRequest(): ReadableStreamBYOBRequest | null;
|
|
99
|
-
/**
|
|
100
|
-
* Returns the desired size to fill the controlled stream's internal queue. It can be negative, if the queue is
|
|
101
|
-
* over-full. An underlying byte source ought to use this information to determine when and how to apply backpressure.
|
|
102
|
-
*/
|
|
103
|
-
get desiredSize(): number | null;
|
|
104
|
-
/**
|
|
105
|
-
* Closes the controlled readable stream. Consumers will still be able to read any previously-enqueued chunks from
|
|
106
|
-
* the stream, but once those are read, the stream will become closed.
|
|
107
|
-
*/
|
|
108
|
-
close(): void;
|
|
109
|
-
/**
|
|
110
|
-
* Enqueues the given chunk chunk in the controlled readable stream.
|
|
111
|
-
* The chunk has to be an `ArrayBufferView` instance, or else a `TypeError` will be thrown.
|
|
112
|
-
*/
|
|
113
|
-
enqueue(chunk: ArrayBufferView): void;
|
|
114
|
-
/**
|
|
115
|
-
* Errors the controlled readable stream, making all future interactions with it fail with the given error `e`.
|
|
116
|
-
*/
|
|
117
|
-
error(e?: any): void;
|
|
89
|
+
interface ReadableStreamGetReaderOptions {
|
|
90
|
+
mode?: 'byob';
|
|
118
91
|
}
|
|
119
|
-
|
|
120
92
|
/**
|
|
121
|
-
*
|
|
93
|
+
* Options for {@link ReadableStreamBYOBReader.read | reading} a stream
|
|
94
|
+
* with a {@link ReadableStreamBYOBReader | BYOB reader}.
|
|
122
95
|
*
|
|
123
96
|
* @public
|
|
124
97
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
highWaterMark?: number;
|
|
128
|
-
size?: undefined;
|
|
129
|
-
});
|
|
130
|
-
constructor(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>);
|
|
131
|
-
/**
|
|
132
|
-
* Whether or not the readable stream is locked to a {@link ReadableStreamDefaultReader | reader}.
|
|
133
|
-
*/
|
|
134
|
-
get locked(): boolean;
|
|
135
|
-
/**
|
|
136
|
-
* Cancels the stream, signaling a loss of interest in the stream by a consumer.
|
|
137
|
-
*
|
|
138
|
-
* The supplied `reason` argument will be given to the underlying source's {@link UnderlyingSource.cancel | cancel()}
|
|
139
|
-
* method, which might or might not use it.
|
|
140
|
-
*/
|
|
141
|
-
cancel(reason?: any): Promise<void>;
|
|
142
|
-
/**
|
|
143
|
-
* Creates a {@link ReadableStreamBYOBReader} and locks the stream to the new reader.
|
|
144
|
-
*
|
|
145
|
-
* This call behaves the same way as the no-argument variant, except that it only works on readable byte streams,
|
|
146
|
-
* i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading.
|
|
147
|
-
* The returned BYOB reader provides the ability to directly read individual chunks from the stream via its
|
|
148
|
-
* {@link ReadableStreamBYOBReader.read | read()} method, into developer-supplied buffers, allowing more precise
|
|
149
|
-
* control over allocation.
|
|
150
|
-
*/
|
|
151
|
-
getReader(options: {
|
|
152
|
-
mode: 'byob';
|
|
153
|
-
}): ReadableStreamBYOBReader;
|
|
154
|
-
/**
|
|
155
|
-
* Creates a {@link ReadableStreamDefaultReader} and locks the stream to the new reader.
|
|
156
|
-
* While the stream is locked, no other reader can be acquired until this one is released.
|
|
157
|
-
*
|
|
158
|
-
* This functionality is especially useful for creating abstractions that desire the ability to consume a stream
|
|
159
|
-
* in its entirety. By getting a reader for the stream, you can ensure nobody else can interleave reads with yours
|
|
160
|
-
* or cancel the stream, which would interfere with your abstraction.
|
|
161
|
-
*/
|
|
162
|
-
getReader(): ReadableStreamDefaultReader<R>;
|
|
163
|
-
/**
|
|
164
|
-
* Creates a {@link ReadableStreamReader} and locks the stream to the new reader.
|
|
165
|
-
*/
|
|
166
|
-
getReader(options?: ReadableStreamGetReaderOptions | undefined): ReadableStreamReader<R>;
|
|
167
|
-
/**
|
|
168
|
-
* Provides a convenient, chainable way of piping this readable stream through a transform stream
|
|
169
|
-
* (or any other `{ writable, readable }` pair). It simply {@link ReadableStream.pipeTo | pipes} the stream
|
|
170
|
-
* into the writable side of the supplied pair, and returns the readable side for further use.
|
|
171
|
-
*
|
|
172
|
-
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
|
|
173
|
-
*/
|
|
174
|
-
pipeThrough<RS extends ReadableStream>(transform: {
|
|
175
|
-
readable: RS;
|
|
176
|
-
writable: WritableStream<R>;
|
|
177
|
-
}, options?: StreamPipeOptions): RS;
|
|
178
|
-
/**
|
|
179
|
-
* Pipes this readable stream to a given writable stream. The way in which the piping process behaves under
|
|
180
|
-
* various error conditions can be customized with a number of passed options. It returns a promise that fulfills
|
|
181
|
-
* when the piping process completes successfully, or rejects if any errors were encountered.
|
|
182
|
-
*
|
|
183
|
-
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
|
|
184
|
-
*/
|
|
185
|
-
pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
|
|
186
|
-
/**
|
|
187
|
-
* Tees this readable stream, returning a two-element array containing the two resulting branches as
|
|
188
|
-
* new {@link ReadableStream} instances.
|
|
189
|
-
*
|
|
190
|
-
* Teeing a stream will lock it, preventing any other consumer from acquiring a reader.
|
|
191
|
-
* To cancel the stream, cancel both of the resulting branches; a composite cancellation reason will then be
|
|
192
|
-
* propagated to the stream's underlying source.
|
|
193
|
-
*
|
|
194
|
-
* Note that the chunks seen in each branch will be the same object. If the chunks are not immutable,
|
|
195
|
-
* this could allow interference between the two branches.
|
|
196
|
-
*/
|
|
197
|
-
tee(): [ReadableStream<R>, ReadableStream<R>];
|
|
198
|
-
/**
|
|
199
|
-
* Asynchronously iterates over the chunks in the stream's internal queue.
|
|
200
|
-
*
|
|
201
|
-
* Asynchronously iterating over the stream will lock it, preventing any other consumer from acquiring a reader.
|
|
202
|
-
* The lock will be released if the async iterator's {@link ReadableStreamAsyncIterator.return | return()} method
|
|
203
|
-
* is called, e.g. by breaking out of the loop.
|
|
204
|
-
*
|
|
205
|
-
* By default, calling the async iterator's {@link ReadableStreamAsyncIterator.return | return()} method will also
|
|
206
|
-
* cancel the stream. To prevent this, use the stream's {@link ReadableStream.values | values()} method, passing
|
|
207
|
-
* `true` for the `preventCancel` option.
|
|
208
|
-
*/
|
|
209
|
-
values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
|
210
|
-
/**
|
|
211
|
-
* {@inheritDoc ReadableStream.values}
|
|
212
|
-
*/
|
|
213
|
-
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
|
214
|
-
/**
|
|
215
|
-
* Creates a new ReadableStream wrapping the provided iterable or async iterable.
|
|
216
|
-
*
|
|
217
|
-
* This can be used to adapt various kinds of objects into a readable stream,
|
|
218
|
-
* such as an array, an async generator, or a Node.js readable stream.
|
|
219
|
-
*/
|
|
220
|
-
static from<R>(asyncIterable: Iterable<R> | AsyncIterable<R> | ReadableStreamLike<R>): ReadableStream<R>;
|
|
98
|
+
interface ReadableStreamBYOBReaderReadOptions {
|
|
99
|
+
min?: number;
|
|
221
100
|
}
|
|
222
|
-
|
|
223
101
|
/**
|
|
224
|
-
*
|
|
102
|
+
* A result returned by {@link ReadableStreamBYOBReader.read}.
|
|
225
103
|
*
|
|
226
104
|
* @public
|
|
227
105
|
*/
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
|
|
106
|
+
type ReadableStreamBYOBReadResult<T extends ArrayBufferView> = {
|
|
107
|
+
done: false;
|
|
108
|
+
value: T;
|
|
109
|
+
} | {
|
|
110
|
+
done: true;
|
|
111
|
+
value: T | undefined;
|
|
112
|
+
};
|
|
233
113
|
/**
|
|
234
114
|
* A BYOB reader vended by a {@link ReadableStream}.
|
|
235
115
|
*
|
|
236
116
|
* @public
|
|
237
117
|
*/
|
|
238
118
|
export declare class ReadableStreamBYOBReader {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
119
|
+
constructor(stream: ReadableStream<Uint8Array>);
|
|
120
|
+
/**
|
|
121
|
+
* Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
|
|
122
|
+
* the reader's lock is released before the stream finishes closing.
|
|
123
|
+
*/
|
|
124
|
+
get closed(): Promise<undefined>;
|
|
125
|
+
/**
|
|
126
|
+
* If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
|
|
127
|
+
*/
|
|
128
|
+
cancel(reason?: any): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Attempts to reads bytes into view, and returns a promise resolved with the result.
|
|
131
|
+
*
|
|
132
|
+
* If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source.
|
|
133
|
+
*/
|
|
134
|
+
read<T extends ArrayBufferView>(view: T, options?: ReadableStreamBYOBReaderReadOptions): Promise<ReadableStreamBYOBReadResult<T>>;
|
|
135
|
+
/**
|
|
136
|
+
* Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active.
|
|
137
|
+
* If the associated stream is errored when the lock is released, the reader will appear errored in the same way
|
|
138
|
+
* from now on; otherwise, the reader will appear closed.
|
|
139
|
+
*
|
|
140
|
+
* A reader's lock cannot be released while it still has a pending read request, i.e., if a promise returned by
|
|
141
|
+
* the reader's {@link ReadableStreamBYOBReader.read | read()} method has not yet been settled. Attempting to
|
|
142
|
+
* do so will throw a `TypeError` and leave the reader locked to the stream.
|
|
143
|
+
*/
|
|
144
|
+
releaseLock(): void;
|
|
265
145
|
}
|
|
266
|
-
|
|
146
|
+
/** @public */
|
|
147
|
+
type UnderlyingSinkStartCallback = (controller: WritableStreamDefaultController) => void | PromiseLike<void>;
|
|
148
|
+
/** @public */
|
|
149
|
+
type UnderlyingSinkWriteCallback<W> = (chunk: W, controller: WritableStreamDefaultController) => void | PromiseLike<void>;
|
|
150
|
+
/** @public */
|
|
151
|
+
type UnderlyingSinkCloseCallback = () => void | PromiseLike<void>;
|
|
152
|
+
/** @public */
|
|
153
|
+
type UnderlyingSinkAbortCallback = (reason: any) => void | PromiseLike<void>;
|
|
267
154
|
/**
|
|
268
|
-
*
|
|
269
|
-
* with a {@link ReadableStreamBYOBReader | BYOB reader}.
|
|
155
|
+
* An underlying sink for constructing a {@link WritableStream}.
|
|
270
156
|
*
|
|
271
157
|
* @public
|
|
272
158
|
*/
|
|
273
|
-
|
|
274
|
-
|
|
159
|
+
interface UnderlyingSink<W = any> {
|
|
160
|
+
/**
|
|
161
|
+
* A function that is called immediately during creation of the {@link WritableStream}.
|
|
162
|
+
*/
|
|
163
|
+
start?: UnderlyingSinkStartCallback;
|
|
164
|
+
/**
|
|
165
|
+
* A function that is called when a new chunk of data is ready to be written to the underlying sink. The stream
|
|
166
|
+
* implementation guarantees that this function will be called only after previous writes have succeeded, and never
|
|
167
|
+
* before {@link UnderlyingSink.start | start()} has succeeded or after {@link UnderlyingSink.close | close()} or
|
|
168
|
+
* {@link UnderlyingSink.abort | abort()} have been called.
|
|
169
|
+
*
|
|
170
|
+
* This function is used to actually send the data to the resource presented by the underlying sink, for example by
|
|
171
|
+
* calling a lower-level API.
|
|
172
|
+
*/
|
|
173
|
+
write?: UnderlyingSinkWriteCallback<W>;
|
|
174
|
+
/**
|
|
175
|
+
* A function that is called after the producer signals, via
|
|
176
|
+
* {@link WritableStreamDefaultWriter.close | writer.close()}, that they are done writing chunks to the stream, and
|
|
177
|
+
* subsequently all queued-up writes have successfully completed.
|
|
178
|
+
*
|
|
179
|
+
* This function can perform any actions necessary to finalize or flush writes to the underlying sink, and release
|
|
180
|
+
* access to any held resources.
|
|
181
|
+
*/
|
|
182
|
+
close?: UnderlyingSinkCloseCallback;
|
|
183
|
+
/**
|
|
184
|
+
* A function that is called after the producer signals, via {@link WritableStream.abort | stream.abort()} or
|
|
185
|
+
* {@link WritableStreamDefaultWriter.abort | writer.abort()}, that they wish to abort the stream. It takes as its
|
|
186
|
+
* argument the same value as was passed to those methods by the producer.
|
|
187
|
+
*
|
|
188
|
+
* Writable streams can additionally be aborted under certain conditions during piping; see the definition of the
|
|
189
|
+
* {@link ReadableStream.pipeTo | pipeTo()} method for more details.
|
|
190
|
+
*
|
|
191
|
+
* This function can clean up any held resources, much like {@link UnderlyingSink.close | close()}, but perhaps with
|
|
192
|
+
* some custom handling.
|
|
193
|
+
*/
|
|
194
|
+
abort?: UnderlyingSinkAbortCallback;
|
|
195
|
+
type?: undefined;
|
|
275
196
|
}
|
|
276
|
-
|
|
277
197
|
/**
|
|
278
|
-
* A
|
|
198
|
+
* A signal object that allows you to communicate with a request and abort it if required
|
|
199
|
+
* via its associated `AbortController` object.
|
|
200
|
+
*
|
|
201
|
+
* @remarks
|
|
202
|
+
* This is equivalent to the `AbortSignal` interface defined in TypeScript's DOM types or `@types/node`.
|
|
279
203
|
*
|
|
280
204
|
* @public
|
|
281
205
|
*/
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
206
|
+
type AbortSignal = typeof globalThis extends {
|
|
207
|
+
AbortSignal: {
|
|
208
|
+
prototype: infer T;
|
|
209
|
+
};
|
|
210
|
+
} ? T : {
|
|
211
|
+
aborted: boolean;
|
|
212
|
+
readonly reason?: any;
|
|
213
|
+
addEventListener(type: 'abort', listener: () => void): void;
|
|
214
|
+
removeEventListener(type: 'abort', listener: () => void): void;
|
|
288
215
|
};
|
|
289
|
-
|
|
290
216
|
/**
|
|
291
|
-
* A
|
|
217
|
+
* A writable stream represents a destination for data, into which you can write.
|
|
292
218
|
*
|
|
293
219
|
* @public
|
|
294
220
|
*/
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
221
|
+
declare class WritableStream<W = any> {
|
|
222
|
+
constructor(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>);
|
|
223
|
+
/**
|
|
224
|
+
* Returns whether or not the writable stream is locked to a writer.
|
|
225
|
+
*/
|
|
226
|
+
get locked(): boolean;
|
|
227
|
+
/**
|
|
228
|
+
* Aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be
|
|
229
|
+
* immediately moved to an errored state, with any queued-up writes discarded. This will also execute any abort
|
|
230
|
+
* mechanism of the underlying sink.
|
|
231
|
+
*
|
|
232
|
+
* The returned promise will fulfill if the stream shuts down successfully, or reject if the underlying sink signaled
|
|
233
|
+
* that there was an error doing so. Additionally, it will reject with a `TypeError` (without attempting to cancel
|
|
234
|
+
* the stream) if the stream is currently locked.
|
|
235
|
+
*/
|
|
236
|
+
abort(reason?: any): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Closes the stream. The underlying sink will finish processing any previously-written chunks, before invoking its
|
|
239
|
+
* close behavior. During this time any further attempts to write will fail (without erroring the stream).
|
|
240
|
+
*
|
|
241
|
+
* The method returns a promise that will fulfill if all remaining chunks are successfully written and the stream
|
|
242
|
+
* successfully closes, or rejects if an error is encountered during this process. Additionally, it will reject with
|
|
243
|
+
* a `TypeError` (without attempting to cancel the stream) if the stream is currently locked.
|
|
244
|
+
*/
|
|
245
|
+
close(): Promise<undefined>;
|
|
246
|
+
/**
|
|
247
|
+
* Creates a {@link WritableStreamDefaultWriter | writer} and locks the stream to the new writer. While the stream
|
|
248
|
+
* is locked, no other writer can be acquired until this one is released.
|
|
249
|
+
*
|
|
250
|
+
* This functionality is especially useful for creating abstractions that desire the ability to write to a stream
|
|
251
|
+
* without interruption or interleaving. By getting a writer for the stream, you can ensure nobody else can write at
|
|
252
|
+
* the same time, which would cause the resulting written data to be unpredictable and probably useless.
|
|
253
|
+
*/
|
|
254
|
+
getWriter(): WritableStreamDefaultWriter<W>;
|
|
317
255
|
}
|
|
318
|
-
|
|
319
256
|
/**
|
|
320
|
-
*
|
|
257
|
+
* A default writer vended by a {@link WritableStream}.
|
|
321
258
|
*
|
|
322
259
|
* @public
|
|
323
260
|
*/
|
|
324
|
-
export declare class
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
261
|
+
export declare class WritableStreamDefaultWriter<W = any> {
|
|
262
|
+
constructor(stream: WritableStream<W>);
|
|
263
|
+
/**
|
|
264
|
+
* Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
|
|
265
|
+
* the writer’s lock is released before the stream finishes closing.
|
|
266
|
+
*/
|
|
267
|
+
get closed(): Promise<undefined>;
|
|
268
|
+
/**
|
|
269
|
+
* Returns the desired size to fill the stream’s internal queue. It can be negative, if the queue is over-full.
|
|
270
|
+
* A producer can use this information to determine the right amount of data to write.
|
|
271
|
+
*
|
|
272
|
+
* It will be `null` if the stream cannot be successfully written to (due to either being errored, or having an abort
|
|
273
|
+
* queued up). It will return zero if the stream is closed. And the getter will throw an exception if invoked when
|
|
274
|
+
* the writer’s lock is released.
|
|
275
|
+
*/
|
|
276
|
+
get desiredSize(): number | null;
|
|
277
|
+
/**
|
|
278
|
+
* Returns a promise that will be fulfilled when the desired size to fill the stream’s internal queue transitions
|
|
279
|
+
* from non-positive to positive, signaling that it is no longer applying backpressure. Once the desired size dips
|
|
280
|
+
* back to zero or below, the getter will return a new promise that stays pending until the next transition.
|
|
281
|
+
*
|
|
282
|
+
* If the stream becomes errored or aborted, or the writer’s lock is released, the returned promise will become
|
|
283
|
+
* rejected.
|
|
284
|
+
*/
|
|
285
|
+
get ready(): Promise<undefined>;
|
|
286
|
+
/**
|
|
287
|
+
* If the reader is active, behaves the same as {@link WritableStream.abort | stream.abort(reason)}.
|
|
288
|
+
*/
|
|
289
|
+
abort(reason?: any): Promise<void>;
|
|
290
|
+
/**
|
|
291
|
+
* If the reader is active, behaves the same as {@link WritableStream.close | stream.close()}.
|
|
292
|
+
*/
|
|
293
|
+
close(): Promise<void>;
|
|
294
|
+
/**
|
|
295
|
+
* Releases the writer’s lock on the corresponding stream. After the lock is released, the writer is no longer active.
|
|
296
|
+
* If the associated stream is errored when the lock is released, the writer will appear errored in the same way from
|
|
297
|
+
* now on; otherwise, the writer will appear closed.
|
|
298
|
+
*
|
|
299
|
+
* Note that the lock can still be released even if some ongoing writes have not yet finished (i.e. even if the
|
|
300
|
+
* promises returned from previous calls to {@link WritableStreamDefaultWriter.write | write()} have not yet settled).
|
|
301
|
+
* It’s not necessary to hold the lock on the writer for the duration of the write; the lock instead simply prevents
|
|
302
|
+
* other producers from writing in an interleaved manner.
|
|
303
|
+
*/
|
|
304
|
+
releaseLock(): void;
|
|
305
|
+
/**
|
|
306
|
+
* Writes the given chunk to the writable stream, by waiting until any previous writes have finished successfully,
|
|
307
|
+
* and then sending the chunk to the underlying sink's {@link UnderlyingSink.write | write()} method. It will return
|
|
308
|
+
* a promise that fulfills with undefined upon a successful write, or rejects if the write fails or stream becomes
|
|
309
|
+
* errored before the writing process is initiated.
|
|
310
|
+
*
|
|
311
|
+
* Note that what "success" means is up to the underlying sink; it might indicate simply that the chunk has been
|
|
312
|
+
* accepted, and not necessarily that it is safely saved to its ultimate destination.
|
|
313
|
+
*/
|
|
314
|
+
write(chunk: W): Promise<void>;
|
|
344
315
|
}
|
|
345
|
-
|
|
346
316
|
/**
|
|
347
|
-
*
|
|
317
|
+
* Allows control of a {@link WritableStream | writable stream}'s state and internal queue.
|
|
348
318
|
*
|
|
349
319
|
* @public
|
|
350
320
|
*/
|
|
351
|
-
export declare class
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
* A reader's lock cannot be released while it still has a pending read request, i.e., if a promise returned by
|
|
374
|
-
* the reader's {@link ReadableStreamDefaultReader.read | read()} method has not yet been settled. Attempting to
|
|
375
|
-
* do so will throw a `TypeError` and leave the reader locked to the stream.
|
|
376
|
-
*/
|
|
377
|
-
releaseLock(): void;
|
|
321
|
+
export declare class WritableStreamDefaultController<W = any> {
|
|
322
|
+
private constructor();
|
|
323
|
+
/**
|
|
324
|
+
* The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted.
|
|
325
|
+
*
|
|
326
|
+
* @deprecated
|
|
327
|
+
* This property has been removed from the specification, see https://github.com/whatwg/streams/pull/1177.
|
|
328
|
+
* Use {@link WritableStreamDefaultController.signal}'s `reason` instead.
|
|
329
|
+
*/
|
|
330
|
+
get abortReason(): any;
|
|
331
|
+
/**
|
|
332
|
+
* An `AbortSignal` that can be used to abort the pending write or close operation when the stream is aborted.
|
|
333
|
+
*/
|
|
334
|
+
get signal(): AbortSignal;
|
|
335
|
+
/**
|
|
336
|
+
* Closes the controlled writable stream, making all future interactions with it fail with the given error `e`.
|
|
337
|
+
*
|
|
338
|
+
* This method is rarely used, since usually it suffices to return a rejected promise from one of the underlying
|
|
339
|
+
* sink's methods. However, it can be useful for suddenly shutting down a stream in response to an event outside the
|
|
340
|
+
* normal lifecycle of interactions with the underlying sink.
|
|
341
|
+
*/
|
|
342
|
+
error(e?: any): void;
|
|
378
343
|
}
|
|
379
|
-
|
|
380
344
|
/**
|
|
381
|
-
*
|
|
345
|
+
* Allows control of a {@link ReadableStream | readable stream}'s state and internal queue.
|
|
382
346
|
*
|
|
383
347
|
* @public
|
|
384
348
|
*/
|
|
385
|
-
export declare
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
349
|
+
export declare class ReadableStreamDefaultController<R> {
|
|
350
|
+
private constructor();
|
|
351
|
+
/**
|
|
352
|
+
* Returns the desired size to fill the controlled stream's internal queue. It can be negative, if the queue is
|
|
353
|
+
* over-full. An underlying source ought to use this information to determine when and how to apply backpressure.
|
|
354
|
+
*/
|
|
355
|
+
get desiredSize(): number | null;
|
|
356
|
+
/**
|
|
357
|
+
* Closes the controlled readable stream. Consumers will still be able to read any previously-enqueued chunks from
|
|
358
|
+
* the stream, but once those are read, the stream will become closed.
|
|
359
|
+
*/
|
|
360
|
+
close(): void;
|
|
361
|
+
/**
|
|
362
|
+
* Enqueues the given chunk `chunk` in the controlled readable stream.
|
|
363
|
+
*/
|
|
364
|
+
enqueue(chunk: R): void;
|
|
365
|
+
/**
|
|
366
|
+
* Errors the controlled readable stream, making all future interactions with it fail with the given error `e`.
|
|
367
|
+
*/
|
|
368
|
+
error(e?: any): void;
|
|
390
369
|
}
|
|
391
|
-
|
|
370
|
+
/** @public */
|
|
371
|
+
type UnderlyingSourceStartCallback<R> = (controller: ReadableStreamDefaultController<R>) => void | PromiseLike<void>;
|
|
372
|
+
/** @public */
|
|
373
|
+
type UnderlyingSourcePullCallback<R> = (controller: ReadableStreamDefaultController<R>) => void | PromiseLike<void>;
|
|
374
|
+
/** @public */
|
|
375
|
+
type UnderlyingByteSourceStartCallback = (controller: ReadableByteStreamController) => void | PromiseLike<void>;
|
|
376
|
+
/** @public */
|
|
377
|
+
type UnderlyingByteSourcePullCallback = (controller: ReadableByteStreamController) => void | PromiseLike<void>;
|
|
378
|
+
/** @public */
|
|
379
|
+
type UnderlyingSourceCancelCallback = (reason: any) => void | PromiseLike<void>;
|
|
392
380
|
/**
|
|
393
|
-
*
|
|
381
|
+
* An underlying source for constructing a {@link ReadableStream}.
|
|
394
382
|
*
|
|
395
383
|
* @public
|
|
396
384
|
*/
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
385
|
+
interface UnderlyingSource<R = any> {
|
|
386
|
+
/**
|
|
387
|
+
* A function that is called immediately during creation of the {@link ReadableStream}.
|
|
388
|
+
*/
|
|
389
|
+
start?: UnderlyingSourceStartCallback<R>;
|
|
390
|
+
/**
|
|
391
|
+
* A function that is called whenever the stream’s internal queue of chunks becomes not full,
|
|
392
|
+
* i.e. whenever the queue’s desired size becomes positive. Generally, it will be called repeatedly
|
|
393
|
+
* until the queue reaches its high water mark (i.e. until the desired size becomes non-positive).
|
|
394
|
+
*/
|
|
395
|
+
pull?: UnderlyingSourcePullCallback<R>;
|
|
396
|
+
/**
|
|
397
|
+
* A function that is called whenever the consumer cancels the stream, via
|
|
398
|
+
* {@link ReadableStream.cancel | stream.cancel()},
|
|
399
|
+
* {@link ReadableStreamDefaultReader.cancel | defaultReader.cancel()}, or
|
|
400
|
+
* {@link ReadableStreamBYOBReader.cancel | byobReader.cancel()}.
|
|
401
|
+
* It takes as its argument the same value as was passed to those methods by the consumer.
|
|
402
|
+
*/
|
|
403
|
+
cancel?: UnderlyingSourceCancelCallback;
|
|
404
|
+
type?: undefined;
|
|
405
|
+
}
|
|
405
406
|
/**
|
|
406
|
-
*
|
|
407
|
+
* An underlying byte source for constructing a {@link ReadableStream}.
|
|
407
408
|
*
|
|
408
409
|
* @public
|
|
409
410
|
*/
|
|
410
|
-
|
|
411
|
-
|
|
411
|
+
interface UnderlyingByteSource {
|
|
412
|
+
/**
|
|
413
|
+
* {@inheritDoc UnderlyingSource.start}
|
|
414
|
+
*/
|
|
415
|
+
start?: UnderlyingByteSourceStartCallback;
|
|
416
|
+
/**
|
|
417
|
+
* {@inheritDoc UnderlyingSource.pull}
|
|
418
|
+
*/
|
|
419
|
+
pull?: UnderlyingByteSourcePullCallback;
|
|
420
|
+
/**
|
|
421
|
+
* {@inheritDoc UnderlyingSource.cancel}
|
|
422
|
+
*/
|
|
423
|
+
cancel?: UnderlyingSourceCancelCallback;
|
|
424
|
+
/**
|
|
425
|
+
* Can be set to "bytes" to signal that the constructed {@link ReadableStream} is a readable byte stream.
|
|
426
|
+
* This ensures that the resulting {@link ReadableStream} will successfully be able to vend BYOB readers via its
|
|
427
|
+
* {@link ReadableStream.(getReader:1) | getReader()} method.
|
|
428
|
+
* It also affects the controller argument passed to the {@link UnderlyingByteSource.start | start()}
|
|
429
|
+
* and {@link UnderlyingByteSource.pull | pull()} methods.
|
|
430
|
+
*/
|
|
431
|
+
type: 'bytes';
|
|
432
|
+
/**
|
|
433
|
+
* Can be set to a positive integer to cause the implementation to automatically allocate buffers for the
|
|
434
|
+
* underlying source code to write into. In this case, when a consumer is using a default reader, the stream
|
|
435
|
+
* implementation will automatically allocate an ArrayBuffer of the given size, so that
|
|
436
|
+
* {@link ReadableByteStreamController.byobRequest | controller.byobRequest} is always present,
|
|
437
|
+
* as if the consumer was using a BYOB reader.
|
|
438
|
+
*/
|
|
439
|
+
autoAllocateChunkSize?: number;
|
|
412
440
|
}
|
|
413
|
-
|
|
414
441
|
/**
|
|
415
|
-
*
|
|
442
|
+
* A pull-into request in a {@link ReadableByteStreamController}.
|
|
416
443
|
*
|
|
417
444
|
* @public
|
|
418
445
|
*/
|
|
419
|
-
export declare
|
|
420
|
-
|
|
446
|
+
export declare class ReadableStreamBYOBRequest {
|
|
447
|
+
private constructor();
|
|
448
|
+
/**
|
|
449
|
+
* Returns the view for writing in to, or `null` if the BYOB request has already been responded to.
|
|
450
|
+
*/
|
|
451
|
+
get view(): ArrayBufferView<ArrayBuffer> | null;
|
|
452
|
+
/**
|
|
453
|
+
* Indicates to the associated readable byte stream that `bytesWritten` bytes were written into
|
|
454
|
+
* {@link ReadableStreamBYOBRequest.view | view}, causing the result be surfaced to the consumer.
|
|
455
|
+
*
|
|
456
|
+
* After this method is called, {@link ReadableStreamBYOBRequest.view | view} will be transferred and no longer
|
|
457
|
+
* modifiable.
|
|
458
|
+
*/
|
|
459
|
+
respond(bytesWritten: number): void;
|
|
460
|
+
/**
|
|
461
|
+
* Indicates to the associated readable byte stream that instead of writing into
|
|
462
|
+
* {@link ReadableStreamBYOBRequest.view | view}, the underlying byte source is providing a new `ArrayBufferView`,
|
|
463
|
+
* which will be given to the consumer of the readable byte stream.
|
|
464
|
+
*
|
|
465
|
+
* After this method is called, `view` will be transferred and no longer modifiable.
|
|
466
|
+
*/
|
|
467
|
+
respondWithNewView(view: ArrayBufferView): void;
|
|
421
468
|
}
|
|
422
|
-
|
|
423
469
|
/**
|
|
424
|
-
*
|
|
470
|
+
* Allows control of a {@link ReadableStream | readable byte stream}'s state and internal queue.
|
|
425
471
|
*
|
|
426
472
|
* @public
|
|
427
473
|
*/
|
|
428
|
-
export declare
|
|
429
|
-
|
|
430
|
-
|
|
474
|
+
export declare class ReadableByteStreamController {
|
|
475
|
+
private constructor();
|
|
476
|
+
/**
|
|
477
|
+
* Returns the current BYOB pull request, or `null` if there isn't one.
|
|
478
|
+
*/
|
|
479
|
+
get byobRequest(): ReadableStreamBYOBRequest | null;
|
|
480
|
+
/**
|
|
481
|
+
* Returns the desired size to fill the controlled stream's internal queue. It can be negative, if the queue is
|
|
482
|
+
* over-full. An underlying byte source ought to use this information to determine when and how to apply backpressure.
|
|
483
|
+
*/
|
|
484
|
+
get desiredSize(): number | null;
|
|
485
|
+
/**
|
|
486
|
+
* Closes the controlled readable stream. Consumers will still be able to read any previously-enqueued chunks from
|
|
487
|
+
* the stream, but once those are read, the stream will become closed.
|
|
488
|
+
*/
|
|
489
|
+
close(): void;
|
|
490
|
+
/**
|
|
491
|
+
* Enqueues the given chunk chunk in the controlled readable stream.
|
|
492
|
+
* The chunk has to be an `ArrayBufferView` instance, or else a `TypeError` will be thrown.
|
|
493
|
+
*/
|
|
494
|
+
enqueue(chunk: ArrayBufferView): void;
|
|
495
|
+
/**
|
|
496
|
+
* Errors the controlled readable stream, making all future interactions with it fail with the given error `e`.
|
|
497
|
+
*/
|
|
498
|
+
error(e?: any): void;
|
|
431
499
|
}
|
|
432
|
-
|
|
433
500
|
/**
|
|
434
|
-
*
|
|
501
|
+
* Options for {@link ReadableStream.pipeTo | piping} a stream.
|
|
435
502
|
*
|
|
436
503
|
* @public
|
|
437
504
|
*/
|
|
438
|
-
|
|
439
|
-
|
|
505
|
+
interface StreamPipeOptions {
|
|
506
|
+
/**
|
|
507
|
+
* If set to true, {@link ReadableStream.pipeTo} will not abort the writable stream if the readable stream errors.
|
|
508
|
+
*/
|
|
509
|
+
preventAbort?: boolean;
|
|
510
|
+
/**
|
|
511
|
+
* If set to true, {@link ReadableStream.pipeTo} will not cancel the readable stream if the writable stream closes
|
|
512
|
+
* or errors.
|
|
513
|
+
*/
|
|
514
|
+
preventCancel?: boolean;
|
|
515
|
+
/**
|
|
516
|
+
* If set to true, {@link ReadableStream.pipeTo} will not close the writable stream if the readable stream closes.
|
|
517
|
+
*/
|
|
518
|
+
preventClose?: boolean;
|
|
519
|
+
/**
|
|
520
|
+
* Can be set to an {@link AbortSignal} to allow aborting an ongoing pipe operation via the corresponding
|
|
521
|
+
* `AbortController`. In this case, the source readable stream will be canceled, and the destination writable stream
|
|
522
|
+
* aborted, unless the respective options `preventCancel` or `preventAbort` are set.
|
|
523
|
+
*/
|
|
524
|
+
signal?: AbortSignal;
|
|
525
|
+
}
|
|
440
526
|
/**
|
|
441
|
-
*
|
|
442
|
-
* to {@link ReadableStream.pipeThrough}.
|
|
527
|
+
* Options for {@link ReadableStream.values | async iterating} a stream.
|
|
443
528
|
*
|
|
444
529
|
* @public
|
|
445
530
|
*/
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
writable: WritableStream<W>;
|
|
531
|
+
interface ReadableStreamIteratorOptions {
|
|
532
|
+
preventCancel?: boolean;
|
|
449
533
|
}
|
|
450
|
-
|
|
451
534
|
/**
|
|
452
|
-
*
|
|
535
|
+
* A pair of a {@link ReadableStream | readable stream} and {@link WritableStream | writable stream} that can be passed
|
|
536
|
+
* to {@link ReadableStream.pipeThrough}.
|
|
453
537
|
*
|
|
454
538
|
* @public
|
|
455
539
|
*/
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
*/
|
|
460
|
-
preventAbort?: boolean;
|
|
461
|
-
/**
|
|
462
|
-
* If set to true, {@link ReadableStream.pipeTo} will not cancel the readable stream if the writable stream closes
|
|
463
|
-
* or errors.
|
|
464
|
-
*/
|
|
465
|
-
preventCancel?: boolean;
|
|
466
|
-
/**
|
|
467
|
-
* If set to true, {@link ReadableStream.pipeTo} will not close the writable stream if the readable stream closes.
|
|
468
|
-
*/
|
|
469
|
-
preventClose?: boolean;
|
|
470
|
-
/**
|
|
471
|
-
* Can be set to an {@link AbortSignal} to allow aborting an ongoing pipe operation via the corresponding
|
|
472
|
-
* `AbortController`. In this case, the source readable stream will be canceled, and the destination writable stream
|
|
473
|
-
* aborted, unless the respective options `preventCancel` or `preventAbort` are set.
|
|
474
|
-
*/
|
|
475
|
-
signal?: AbortSignal;
|
|
540
|
+
interface ReadableWritablePair<R, W> {
|
|
541
|
+
readable: ReadableStream<R>;
|
|
542
|
+
writable: WritableStream<W>;
|
|
476
543
|
}
|
|
477
|
-
|
|
478
544
|
/**
|
|
479
|
-
* A
|
|
545
|
+
* A common interface for a `ReadadableStream` implementation.
|
|
480
546
|
*
|
|
481
547
|
* @public
|
|
482
548
|
*/
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
*/
|
|
487
|
-
start?: TransformerStartCallback<O>;
|
|
488
|
-
/**
|
|
489
|
-
* A function called when a new chunk originally written to the writable side is ready to be transformed.
|
|
490
|
-
*/
|
|
491
|
-
transform?: TransformerTransformCallback<I, O>;
|
|
492
|
-
/**
|
|
493
|
-
* A function called after all chunks written to the writable side have been transformed by successfully passing
|
|
494
|
-
* through {@link Transformer.transform | transform()}, and the writable side is about to be closed.
|
|
495
|
-
*/
|
|
496
|
-
flush?: TransformerFlushCallback<O>;
|
|
497
|
-
/**
|
|
498
|
-
* A function called when the readable side is cancelled, or when the writable side is aborted.
|
|
499
|
-
*/
|
|
500
|
-
cancel?: TransformerCancelCallback;
|
|
501
|
-
readableType?: undefined;
|
|
502
|
-
writableType?: undefined;
|
|
549
|
+
interface ReadableStreamLike<R = any> {
|
|
550
|
+
readonly locked: boolean;
|
|
551
|
+
getReader(): ReadableStreamDefaultReaderLike<R>;
|
|
503
552
|
}
|
|
504
|
-
|
|
505
|
-
/** @public */
|
|
506
|
-
export declare type TransformerCancelCallback = (reason: any) => void | PromiseLike<void>;
|
|
507
|
-
|
|
508
|
-
/** @public */
|
|
509
|
-
export declare type TransformerFlushCallback<O> = (controller: TransformStreamDefaultController<O>) => void | PromiseLike<void>;
|
|
510
|
-
|
|
511
|
-
/** @public */
|
|
512
|
-
export declare type TransformerStartCallback<O> = (controller: TransformStreamDefaultController<O>) => void | PromiseLike<void>;
|
|
513
|
-
|
|
514
|
-
/** @public */
|
|
515
|
-
export declare type TransformerTransformCallback<I, O> = (chunk: I, controller: TransformStreamDefaultController<O>) => void | PromiseLike<void>;
|
|
516
|
-
|
|
517
553
|
/**
|
|
518
|
-
* A
|
|
519
|
-
* known as its writable side, and a {@link ReadableStream | readable stream}, known as its readable side.
|
|
520
|
-
* In a manner specific to the transform stream in question, writes to the writable side result in new data being
|
|
521
|
-
* made available for reading from the readable side.
|
|
554
|
+
* A common interface for a `ReadableStreamDefaultReader` implementation.
|
|
522
555
|
*
|
|
523
556
|
* @public
|
|
524
557
|
*/
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
get readable(): ReadableStream<O>;
|
|
531
|
-
/**
|
|
532
|
-
* The writable side of the transform stream.
|
|
533
|
-
*/
|
|
534
|
-
get writable(): WritableStream<I>;
|
|
558
|
+
interface ReadableStreamDefaultReaderLike<R = any> {
|
|
559
|
+
readonly closed: Promise<undefined>;
|
|
560
|
+
cancel(reason?: any): Promise<void>;
|
|
561
|
+
read(): Promise<ReadableStreamDefaultReadResult<R>>;
|
|
562
|
+
releaseLock(): void;
|
|
535
563
|
}
|
|
536
|
-
|
|
537
564
|
/**
|
|
538
|
-
*
|
|
565
|
+
* A readable stream represents a source of data, from which you can read.
|
|
539
566
|
*
|
|
540
567
|
* @public
|
|
541
568
|
*/
|
|
542
|
-
export declare class
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
569
|
+
export declare class ReadableStream<R = any> implements AsyncIterable<R> {
|
|
570
|
+
constructor(underlyingSource: UnderlyingByteSource, strategy?: {
|
|
571
|
+
highWaterMark?: number;
|
|
572
|
+
size?: undefined;
|
|
573
|
+
});
|
|
574
|
+
constructor(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>);
|
|
575
|
+
/**
|
|
576
|
+
* Whether or not the readable stream is locked to a {@link ReadableStreamDefaultReader | reader}.
|
|
577
|
+
*/
|
|
578
|
+
get locked(): boolean;
|
|
579
|
+
/**
|
|
580
|
+
* Cancels the stream, signaling a loss of interest in the stream by a consumer.
|
|
581
|
+
*
|
|
582
|
+
* The supplied `reason` argument will be given to the underlying source's {@link UnderlyingSource.cancel | cancel()}
|
|
583
|
+
* method, which might or might not use it.
|
|
584
|
+
*/
|
|
585
|
+
cancel(reason?: any): Promise<void>;
|
|
586
|
+
/**
|
|
587
|
+
* Creates a {@link ReadableStreamBYOBReader} and locks the stream to the new reader.
|
|
588
|
+
*
|
|
589
|
+
* This call behaves the same way as the no-argument variant, except that it only works on readable byte streams,
|
|
590
|
+
* i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading.
|
|
591
|
+
* The returned BYOB reader provides the ability to directly read individual chunks from the stream via its
|
|
592
|
+
* {@link ReadableStreamBYOBReader.read | read()} method, into developer-supplied buffers, allowing more precise
|
|
593
|
+
* control over allocation.
|
|
594
|
+
*/
|
|
595
|
+
getReader(options: {
|
|
596
|
+
mode: 'byob';
|
|
597
|
+
}): ReadableStreamBYOBReader;
|
|
598
|
+
/**
|
|
599
|
+
* Creates a {@link ReadableStreamDefaultReader} and locks the stream to the new reader.
|
|
600
|
+
* While the stream is locked, no other reader can be acquired until this one is released.
|
|
601
|
+
*
|
|
602
|
+
* This functionality is especially useful for creating abstractions that desire the ability to consume a stream
|
|
603
|
+
* in its entirety. By getting a reader for the stream, you can ensure nobody else can interleave reads with yours
|
|
604
|
+
* or cancel the stream, which would interfere with your abstraction.
|
|
605
|
+
*/
|
|
606
|
+
getReader(): ReadableStreamDefaultReader<R>;
|
|
607
|
+
/**
|
|
608
|
+
* Creates a {@link ReadableStreamReader} and locks the stream to the new reader.
|
|
609
|
+
*/
|
|
610
|
+
getReader(options?: ReadableStreamGetReaderOptions | undefined): ReadableStreamReader<R>;
|
|
611
|
+
/**
|
|
612
|
+
* Provides a convenient, chainable way of piping this readable stream through a transform stream
|
|
613
|
+
* (or any other `{ writable, readable }` pair). It simply {@link ReadableStream.pipeTo | pipes} the stream
|
|
614
|
+
* into the writable side of the supplied pair, and returns the readable side for further use.
|
|
615
|
+
*
|
|
616
|
+
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
|
|
617
|
+
*/
|
|
618
|
+
pipeThrough<RS extends ReadableStream>(transform: {
|
|
619
|
+
readable: RS;
|
|
620
|
+
writable: WritableStream<R>;
|
|
621
|
+
}, options?: StreamPipeOptions): RS;
|
|
622
|
+
/**
|
|
623
|
+
* Pipes this readable stream to a given writable stream. The way in which the piping process behaves under
|
|
624
|
+
* various error conditions can be customized with a number of passed options. It returns a promise that fulfills
|
|
625
|
+
* when the piping process completes successfully, or rejects if any errors were encountered.
|
|
626
|
+
*
|
|
627
|
+
* Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
|
|
628
|
+
*/
|
|
629
|
+
pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
|
|
630
|
+
/**
|
|
631
|
+
* Tees this readable stream, returning a two-element array containing the two resulting branches as
|
|
632
|
+
* new {@link ReadableStream} instances.
|
|
633
|
+
*
|
|
634
|
+
* Teeing a stream will lock it, preventing any other consumer from acquiring a reader.
|
|
635
|
+
* To cancel the stream, cancel both of the resulting branches; a composite cancellation reason will then be
|
|
636
|
+
* propagated to the stream's underlying source.
|
|
637
|
+
*
|
|
638
|
+
* Note that the chunks seen in each branch will be the same object. If the chunks are not immutable,
|
|
639
|
+
* this could allow interference between the two branches.
|
|
640
|
+
*/
|
|
641
|
+
tee(): [ReadableStream<R>, ReadableStream<R>];
|
|
642
|
+
/**
|
|
643
|
+
* Asynchronously iterates over the chunks in the stream's internal queue.
|
|
644
|
+
*
|
|
645
|
+
* Asynchronously iterating over the stream will lock it, preventing any other consumer from acquiring a reader.
|
|
646
|
+
* The lock will be released if the async iterator's {@link ReadableStreamAsyncIterator.return | return()} method
|
|
647
|
+
* is called, e.g. by breaking out of the loop.
|
|
648
|
+
*
|
|
649
|
+
* By default, calling the async iterator's {@link ReadableStreamAsyncIterator.return | return()} method will also
|
|
650
|
+
* cancel the stream. To prevent this, use the stream's {@link ReadableStream.values | values()} method, passing
|
|
651
|
+
* `true` for the `preventCancel` option.
|
|
652
|
+
*/
|
|
653
|
+
values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
|
654
|
+
/**
|
|
655
|
+
* {@inheritDoc ReadableStream.values}
|
|
656
|
+
*/
|
|
657
|
+
[Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
|
|
658
|
+
/**
|
|
659
|
+
* Creates a new ReadableStream wrapping the provided iterable or async iterable.
|
|
660
|
+
*
|
|
661
|
+
* This can be used to adapt various kinds of objects into a readable stream,
|
|
662
|
+
* such as an array, an async generator, or a Node.js readable stream.
|
|
663
|
+
*/
|
|
664
|
+
static from<R>(asyncIterable: Iterable<R> | AsyncIterable<R> | ReadableStreamLike<R>): ReadableStream<R>;
|
|
562
665
|
}
|
|
563
|
-
|
|
564
666
|
/**
|
|
565
|
-
*
|
|
667
|
+
* A reader vended by a {@link ReadableStream}.
|
|
566
668
|
*
|
|
567
669
|
* @public
|
|
568
670
|
*/
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
* {@inheritDoc UnderlyingSource.start}
|
|
572
|
-
*/
|
|
573
|
-
start?: UnderlyingByteSourceStartCallback;
|
|
574
|
-
/**
|
|
575
|
-
* {@inheritDoc UnderlyingSource.pull}
|
|
576
|
-
*/
|
|
577
|
-
pull?: UnderlyingByteSourcePullCallback;
|
|
578
|
-
/**
|
|
579
|
-
* {@inheritDoc UnderlyingSource.cancel}
|
|
580
|
-
*/
|
|
581
|
-
cancel?: UnderlyingSourceCancelCallback;
|
|
582
|
-
/**
|
|
583
|
-
* Can be set to "bytes" to signal that the constructed {@link ReadableStream} is a readable byte stream.
|
|
584
|
-
* This ensures that the resulting {@link ReadableStream} will successfully be able to vend BYOB readers via its
|
|
585
|
-
* {@link ReadableStream.(getReader:1) | getReader()} method.
|
|
586
|
-
* It also affects the controller argument passed to the {@link UnderlyingByteSource.start | start()}
|
|
587
|
-
* and {@link UnderlyingByteSource.pull | pull()} methods.
|
|
588
|
-
*/
|
|
589
|
-
type: 'bytes';
|
|
590
|
-
/**
|
|
591
|
-
* Can be set to a positive integer to cause the implementation to automatically allocate buffers for the
|
|
592
|
-
* underlying source code to write into. In this case, when a consumer is using a default reader, the stream
|
|
593
|
-
* implementation will automatically allocate an ArrayBuffer of the given size, so that
|
|
594
|
-
* {@link ReadableByteStreamController.byobRequest | controller.byobRequest} is always present,
|
|
595
|
-
* as if the consumer was using a BYOB reader.
|
|
596
|
-
*/
|
|
597
|
-
autoAllocateChunkSize?: number;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
/** @public */
|
|
601
|
-
export declare type UnderlyingByteSourcePullCallback = (controller: ReadableByteStreamController) => void | PromiseLike<void>;
|
|
602
|
-
|
|
603
|
-
/** @public */
|
|
604
|
-
export declare type UnderlyingByteSourceStartCallback = (controller: ReadableByteStreamController) => void | PromiseLike<void>;
|
|
605
|
-
|
|
671
|
+
type ReadableStreamReader<R> = ReadableStreamDefaultReader<R> | ReadableStreamBYOBReader;
|
|
606
672
|
/**
|
|
607
|
-
*
|
|
673
|
+
* A queuing strategy that counts the number of bytes in each chunk.
|
|
608
674
|
*
|
|
609
675
|
* @public
|
|
610
676
|
*/
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
*
|
|
622
|
-
* This function is used to actually send the data to the resource presented by the underlying sink, for example by
|
|
623
|
-
* calling a lower-level API.
|
|
624
|
-
*/
|
|
625
|
-
write?: UnderlyingSinkWriteCallback<W>;
|
|
626
|
-
/**
|
|
627
|
-
* A function that is called after the producer signals, via
|
|
628
|
-
* {@link WritableStreamDefaultWriter.close | writer.close()}, that they are done writing chunks to the stream, and
|
|
629
|
-
* subsequently all queued-up writes have successfully completed.
|
|
630
|
-
*
|
|
631
|
-
* This function can perform any actions necessary to finalize or flush writes to the underlying sink, and release
|
|
632
|
-
* access to any held resources.
|
|
633
|
-
*/
|
|
634
|
-
close?: UnderlyingSinkCloseCallback;
|
|
635
|
-
/**
|
|
636
|
-
* A function that is called after the producer signals, via {@link WritableStream.abort | stream.abort()} or
|
|
637
|
-
* {@link WritableStreamDefaultWriter.abort | writer.abort()}, that they wish to abort the stream. It takes as its
|
|
638
|
-
* argument the same value as was passed to those methods by the producer.
|
|
639
|
-
*
|
|
640
|
-
* Writable streams can additionally be aborted under certain conditions during piping; see the definition of the
|
|
641
|
-
* {@link ReadableStream.pipeTo | pipeTo()} method for more details.
|
|
642
|
-
*
|
|
643
|
-
* This function can clean up any held resources, much like {@link UnderlyingSink.close | close()}, but perhaps with
|
|
644
|
-
* some custom handling.
|
|
645
|
-
*/
|
|
646
|
-
abort?: UnderlyingSinkAbortCallback;
|
|
647
|
-
type?: undefined;
|
|
677
|
+
declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {
|
|
678
|
+
constructor(options: QueuingStrategyInit);
|
|
679
|
+
/**
|
|
680
|
+
* Returns the high water mark provided to the constructor.
|
|
681
|
+
*/
|
|
682
|
+
get highWaterMark(): number;
|
|
683
|
+
/**
|
|
684
|
+
* Measures the size of `chunk` by returning the value of its `byteLength` property.
|
|
685
|
+
*/
|
|
686
|
+
get size(): (chunk: ArrayBufferView) => number;
|
|
648
687
|
}
|
|
649
|
-
|
|
650
|
-
/** @public */
|
|
651
|
-
export declare type UnderlyingSinkAbortCallback = (reason: any) => void | PromiseLike<void>;
|
|
652
|
-
|
|
653
|
-
/** @public */
|
|
654
|
-
export declare type UnderlyingSinkCloseCallback = () => void | PromiseLike<void>;
|
|
655
|
-
|
|
656
|
-
/** @public */
|
|
657
|
-
export declare type UnderlyingSinkStartCallback = (controller: WritableStreamDefaultController) => void | PromiseLike<void>;
|
|
658
|
-
|
|
659
|
-
/** @public */
|
|
660
|
-
export declare type UnderlyingSinkWriteCallback<W> = (chunk: W, controller: WritableStreamDefaultController) => void | PromiseLike<void>;
|
|
661
|
-
|
|
662
688
|
/**
|
|
663
|
-
*
|
|
689
|
+
* A queuing strategy that counts the number of chunks.
|
|
664
690
|
*
|
|
665
691
|
* @public
|
|
666
692
|
*/
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
/**
|
|
679
|
-
* A function that is called whenever the consumer cancels the stream, via
|
|
680
|
-
* {@link ReadableStream.cancel | stream.cancel()},
|
|
681
|
-
* {@link ReadableStreamDefaultReader.cancel | defaultReader.cancel()}, or
|
|
682
|
-
* {@link ReadableStreamBYOBReader.cancel | byobReader.cancel()}.
|
|
683
|
-
* It takes as its argument the same value as was passed to those methods by the consumer.
|
|
684
|
-
*/
|
|
685
|
-
cancel?: UnderlyingSourceCancelCallback;
|
|
686
|
-
type?: undefined;
|
|
693
|
+
declare class CountQueuingStrategy implements QueuingStrategy<any> {
|
|
694
|
+
constructor(options: QueuingStrategyInit);
|
|
695
|
+
/**
|
|
696
|
+
* Returns the high water mark provided to the constructor.
|
|
697
|
+
*/
|
|
698
|
+
get highWaterMark(): number;
|
|
699
|
+
/**
|
|
700
|
+
* Measures the size of `chunk` by always returning 1.
|
|
701
|
+
* This ensures that the total queue size is a count of the number of chunks in the queue.
|
|
702
|
+
*/
|
|
703
|
+
get size(): (chunk: any) => 1;
|
|
687
704
|
}
|
|
688
|
-
|
|
689
705
|
/** @public */
|
|
690
|
-
|
|
691
|
-
|
|
706
|
+
type TransformerStartCallback<O> = (controller: TransformStreamDefaultController<O>) => void | PromiseLike<void>;
|
|
692
707
|
/** @public */
|
|
693
|
-
|
|
694
|
-
|
|
708
|
+
type TransformerFlushCallback<O> = (controller: TransformStreamDefaultController<O>) => void | PromiseLike<void>;
|
|
695
709
|
/** @public */
|
|
696
|
-
|
|
697
|
-
|
|
710
|
+
type TransformerTransformCallback<I, O> = (chunk: I, controller: TransformStreamDefaultController<O>) => void | PromiseLike<void>;
|
|
711
|
+
/** @public */
|
|
712
|
+
type TransformerCancelCallback = (reason: any) => void | PromiseLike<void>;
|
|
698
713
|
/**
|
|
699
|
-
* A
|
|
714
|
+
* A transformer for constructing a {@link TransformStream}.
|
|
700
715
|
*
|
|
701
716
|
* @public
|
|
702
717
|
*/
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
* The method returns a promise that will fulfill if all remaining chunks are successfully written and the stream
|
|
724
|
-
* successfully closes, or rejects if an error is encountered during this process. Additionally, it will reject with
|
|
725
|
-
* a `TypeError` (without attempting to cancel the stream) if the stream is currently locked.
|
|
726
|
-
*/
|
|
727
|
-
close(): Promise<undefined>;
|
|
728
|
-
/**
|
|
729
|
-
* Creates a {@link WritableStreamDefaultWriter | writer} and locks the stream to the new writer. While the stream
|
|
730
|
-
* is locked, no other writer can be acquired until this one is released.
|
|
731
|
-
*
|
|
732
|
-
* This functionality is especially useful for creating abstractions that desire the ability to write to a stream
|
|
733
|
-
* without interruption or interleaving. By getting a writer for the stream, you can ensure nobody else can write at
|
|
734
|
-
* the same time, which would cause the resulting written data to be unpredictable and probably useless.
|
|
735
|
-
*/
|
|
736
|
-
getWriter(): WritableStreamDefaultWriter<W>;
|
|
718
|
+
interface Transformer<I = any, O = any> {
|
|
719
|
+
/**
|
|
720
|
+
* A function that is called immediately during creation of the {@link TransformStream}.
|
|
721
|
+
*/
|
|
722
|
+
start?: TransformerStartCallback<O>;
|
|
723
|
+
/**
|
|
724
|
+
* A function called when a new chunk originally written to the writable side is ready to be transformed.
|
|
725
|
+
*/
|
|
726
|
+
transform?: TransformerTransformCallback<I, O>;
|
|
727
|
+
/**
|
|
728
|
+
* A function called after all chunks written to the writable side have been transformed by successfully passing
|
|
729
|
+
* through {@link Transformer.transform | transform()}, and the writable side is about to be closed.
|
|
730
|
+
*/
|
|
731
|
+
flush?: TransformerFlushCallback<O>;
|
|
732
|
+
/**
|
|
733
|
+
* A function called when the readable side is cancelled, or when the writable side is aborted.
|
|
734
|
+
*/
|
|
735
|
+
cancel?: TransformerCancelCallback;
|
|
736
|
+
readableType?: undefined;
|
|
737
|
+
writableType?: undefined;
|
|
737
738
|
}
|
|
738
|
-
|
|
739
739
|
/**
|
|
740
|
-
*
|
|
740
|
+
* A transform stream consists of a pair of streams: a {@link WritableStream | writable stream},
|
|
741
|
+
* known as its writable side, and a {@link ReadableStream | readable stream}, known as its readable side.
|
|
742
|
+
* In a manner specific to the transform stream in question, writes to the writable side result in new data being
|
|
743
|
+
* made available for reading from the readable side.
|
|
741
744
|
*
|
|
742
745
|
* @public
|
|
743
746
|
*/
|
|
744
|
-
export declare class
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
/**
|
|
755
|
-
* An `AbortSignal` that can be used to abort the pending write or close operation when the stream is aborted.
|
|
756
|
-
*/
|
|
757
|
-
get signal(): AbortSignal;
|
|
758
|
-
/**
|
|
759
|
-
* Closes the controlled writable stream, making all future interactions with it fail with the given error `e`.
|
|
760
|
-
*
|
|
761
|
-
* This method is rarely used, since usually it suffices to return a rejected promise from one of the underlying
|
|
762
|
-
* sink's methods. However, it can be useful for suddenly shutting down a stream in response to an event outside the
|
|
763
|
-
* normal lifecycle of interactions with the underlying sink.
|
|
764
|
-
*/
|
|
765
|
-
error(e?: any): void;
|
|
747
|
+
export declare class TransformStream<I = any, O = any> {
|
|
748
|
+
constructor(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>);
|
|
749
|
+
/**
|
|
750
|
+
* The readable side of the transform stream.
|
|
751
|
+
*/
|
|
752
|
+
get readable(): ReadableStream<O>;
|
|
753
|
+
/**
|
|
754
|
+
* The writable side of the transform stream.
|
|
755
|
+
*/
|
|
756
|
+
get writable(): WritableStream<I>;
|
|
766
757
|
}
|
|
767
|
-
|
|
768
758
|
/**
|
|
769
|
-
*
|
|
759
|
+
* Allows control of the {@link ReadableStream} and {@link WritableStream} of the associated {@link TransformStream}.
|
|
770
760
|
*
|
|
771
761
|
* @public
|
|
772
762
|
*/
|
|
773
|
-
export declare class
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
*
|
|
794
|
-
* If the stream becomes errored or aborted, or the writer’s lock is released, the returned promise will become
|
|
795
|
-
* rejected.
|
|
796
|
-
*/
|
|
797
|
-
get ready(): Promise<undefined>;
|
|
798
|
-
/**
|
|
799
|
-
* If the reader is active, behaves the same as {@link WritableStream.abort | stream.abort(reason)}.
|
|
800
|
-
*/
|
|
801
|
-
abort(reason?: any): Promise<void>;
|
|
802
|
-
/**
|
|
803
|
-
* If the reader is active, behaves the same as {@link WritableStream.close | stream.close()}.
|
|
804
|
-
*/
|
|
805
|
-
close(): Promise<void>;
|
|
806
|
-
/**
|
|
807
|
-
* Releases the writer’s lock on the corresponding stream. After the lock is released, the writer is no longer active.
|
|
808
|
-
* If the associated stream is errored when the lock is released, the writer will appear errored in the same way from
|
|
809
|
-
* now on; otherwise, the writer will appear closed.
|
|
810
|
-
*
|
|
811
|
-
* Note that the lock can still be released even if some ongoing writes have not yet finished (i.e. even if the
|
|
812
|
-
* promises returned from previous calls to {@link WritableStreamDefaultWriter.write | write()} have not yet settled).
|
|
813
|
-
* It’s not necessary to hold the lock on the writer for the duration of the write; the lock instead simply prevents
|
|
814
|
-
* other producers from writing in an interleaved manner.
|
|
815
|
-
*/
|
|
816
|
-
releaseLock(): void;
|
|
817
|
-
/**
|
|
818
|
-
* Writes the given chunk to the writable stream, by waiting until any previous writes have finished successfully,
|
|
819
|
-
* and then sending the chunk to the underlying sink's {@link UnderlyingSink.write | write()} method. It will return
|
|
820
|
-
* a promise that fulfills with undefined upon a successful write, or rejects if the write fails or stream becomes
|
|
821
|
-
* errored before the writing process is initiated.
|
|
822
|
-
*
|
|
823
|
-
* Note that what "success" means is up to the underlying sink; it might indicate simply that the chunk has been
|
|
824
|
-
* accepted, and not necessarily that it is safely saved to its ultimate destination.
|
|
825
|
-
*/
|
|
826
|
-
write(chunk: W): Promise<void>;
|
|
763
|
+
export declare class TransformStreamDefaultController<O> {
|
|
764
|
+
private constructor();
|
|
765
|
+
/**
|
|
766
|
+
* Returns the desired size to fill the readable side’s internal queue. It can be negative, if the queue is over-full.
|
|
767
|
+
*/
|
|
768
|
+
get desiredSize(): number | null;
|
|
769
|
+
/**
|
|
770
|
+
* Enqueues the given chunk `chunk` in the readable side of the controlled transform stream.
|
|
771
|
+
*/
|
|
772
|
+
enqueue(chunk: O): void;
|
|
773
|
+
/**
|
|
774
|
+
* Errors both the readable side and the writable side of the controlled transform stream, making all future
|
|
775
|
+
* interactions with it fail with the given error `e`. Any chunks queued for transformation will be discarded.
|
|
776
|
+
*/
|
|
777
|
+
error(reason?: any): void;
|
|
778
|
+
/**
|
|
779
|
+
* Closes the readable side and errors the writable side of the controlled transform stream. This is useful when the
|
|
780
|
+
* transformer only needs to consume a portion of the chunks written to the writable side.
|
|
781
|
+
*/
|
|
782
|
+
terminate(): void;
|
|
827
783
|
}
|
|
828
|
-
|
|
829
|
-
export { }
|
|
784
|
+
export { type AbortSignal, ByteLengthQueuingStrategy, CountQueuingStrategy, type QueuingStrategy, type QueuingStrategyInit, type QueuingStrategySizeCallback, type ReadableStreamAsyncIterator, type ReadableStreamBYOBReadResult, type ReadableStreamBYOBReaderReadOptions, type ReadableStreamDefaultReadResult, type ReadableStreamDefaultReaderLike, type ReadableStreamGetReaderOptions, type ReadableStreamIteratorOptions, type ReadableStreamLike, type ReadableStreamReader, type ReadableWritablePair, type StreamPipeOptions, type Transformer, type TransformerCancelCallback, type TransformerFlushCallback, type TransformerStartCallback, type TransformerTransformCallback, type UnderlyingByteSource, type UnderlyingByteSourcePullCallback, type UnderlyingByteSourceStartCallback, type UnderlyingSink, type UnderlyingSinkAbortCallback, type UnderlyingSinkCloseCallback, type UnderlyingSinkStartCallback, type UnderlyingSinkWriteCallback, type UnderlyingSource, type UnderlyingSourceCancelCallback, type UnderlyingSourcePullCallback, type UnderlyingSourceStartCallback, WritableStream };
|