web-streams-polyfill 3.3.1 → 3.3.3

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.
@@ -0,0 +1,24 @@
1
+ /// <reference lib="dom" />
2
+ /// <reference lib="esnext.asynciterable" />
3
+ import { ReadableStreamAsyncIterator, ReadableStreamIteratorOptions } from './ponyfill';
4
+ export * from './ponyfill';
5
+ declare global {
6
+ interface ReadableStream<R = any> extends AsyncIterable<R> {
7
+ /**
8
+ * Asynchronously iterates over the chunks in the stream's internal queue.
9
+ *
10
+ * Asynchronously iterating over the stream will lock it, preventing any other consumer from acquiring a reader.
11
+ * The lock will be released if the async iterator's {@link ReadableStreamAsyncIterator.return | return()} method
12
+ * is called, e.g. by breaking out of the loop.
13
+ *
14
+ * By default, calling the async iterator's {@link ReadableStreamAsyncIterator.return | return()} method will also
15
+ * cancel the stream. To prevent this, use the stream's {@link ReadableStream.values | values()} method, passing
16
+ * `true` for the `preventCancel` option.
17
+ */
18
+ values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
19
+ /**
20
+ * {@inheritDoc ReadableStream.values}
21
+ */
22
+ [Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
23
+ }
24
+ }
@@ -126,7 +126,7 @@ export declare class ReadableByteStreamController {
126
126
  *
127
127
  * @public
128
128
  */
129
- export declare class ReadableStream<R = any> {
129
+ export declare class ReadableStream<R = any> implements AsyncIterable<R> {
130
130
  constructor(underlyingSource: UnderlyingByteSource, strategy?: {
131
131
  highWaterMark?: number;
132
132
  size?: undefined;
@@ -213,7 +213,7 @@ export declare class ReadableStream<R = any> {
213
213
  /**
214
214
  * {@inheritDoc ReadableStream.values}
215
215
  */
216
- [Symbol.asyncIterator]: (options?: ReadableStreamIteratorOptions) => ReadableStreamAsyncIterator<R>;
216
+ [Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
217
217
  /**
218
218
  * Creates a new ReadableStream wrapping the provided iterable or async iterable.
219
219
  *
@@ -227,7 +227,7 @@ export declare class ReadableStream<R = any> {
227
227
  *
228
228
  * @public
229
229
  */
230
- export declare interface ReadableStreamAsyncIterator<R> extends AsyncIterator<R> {
230
+ export declare interface ReadableStreamAsyncIterator<R> extends AsyncIterableIterator<R> {
231
231
  next(): Promise<IteratorResult<R>>;
232
232
  return(value?: any): Promise<IteratorResult<any>>;
233
233
  }
@@ -0,0 +1,28 @@
1
+ /// <reference lib="dom" />
2
+ /// <reference lib="es2018.asynciterable" />
3
+
4
+ import type { ReadableStreamAsyncIterator, ReadableStreamIteratorOptions } from './ponyfill';
5
+
6
+ export * from './ponyfill';
7
+
8
+ declare global {
9
+ interface ReadableStream<R = any> extends AsyncIterable<R> {
10
+ /**
11
+ * Asynchronously iterates over the chunks in the stream's internal queue.
12
+ *
13
+ * Asynchronously iterating over the stream will lock it, preventing any other consumer from acquiring a reader.
14
+ * The lock will be released if the async iterator's {@link ReadableStreamAsyncIterator.return | return()} method
15
+ * is called, e.g. by breaking out of the loop.
16
+ *
17
+ * By default, calling the async iterator's {@link ReadableStreamAsyncIterator.return | return()} method will also
18
+ * cancel the stream. To prevent this, use the stream's {@link ReadableStream.values | values()} method, passing
19
+ * `true` for the `preventCancel` option.
20
+ */
21
+ values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
22
+
23
+ /**
24
+ * {@inheritDoc ReadableStream.values}
25
+ */
26
+ [Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
27
+ }
28
+ }
@@ -134,7 +134,7 @@ export declare class ReadableByteStreamController {
134
134
  *
135
135
  * @public
136
136
  */
137
- export declare class ReadableStream<R = any> {
137
+ export declare class ReadableStream<R = any> implements AsyncIterable<R> {
138
138
  constructor(underlyingSource: UnderlyingByteSource, strategy?: {
139
139
  highWaterMark?: number;
140
140
  size?: undefined;
@@ -218,7 +218,7 @@ export declare class ReadableStream<R = any> {
218
218
  /**
219
219
  * {@inheritDoc ReadableStream.values}
220
220
  */
221
- [Symbol.asyncIterator]: (options?: ReadableStreamIteratorOptions) => ReadableStreamAsyncIterator<R>;
221
+ [Symbol.asyncIterator](options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
222
222
  /**
223
223
  * Creates a new ReadableStream wrapping the provided iterable or async iterable.
224
224
  *
@@ -233,7 +233,7 @@ export declare class ReadableStream<R = any> {
233
233
  *
234
234
  * @public
235
235
  */
236
- export declare interface ReadableStreamAsyncIterator<R> extends AsyncIterator<R> {
236
+ export declare interface ReadableStreamAsyncIterator<R> extends AsyncIterableIterator<R> {
237
237
  next(): Promise<IteratorResult<R, undefined>>;
238
238
  return(value?: any): Promise<IteratorResult<any>>;
239
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-streams-polyfill",
3
- "version": "3.3.1",
3
+ "version": "3.3.3",
4
4
  "description": "Web Streams, based on the WHATWG spec reference implementation",
5
5
  "main": "dist/polyfill",
6
6
  "browser": "dist/polyfill.min.js",