web-streams-polyfill 3.0.1 → 3.1.1

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.
@@ -89,7 +89,9 @@ export declare interface QueuingStrategyInit {
89
89
 
90
90
  declare type QueuingStrategySizeCallback<T = any> = (chunk: T) => number;
91
91
 
92
- declare type ReadableByteStream = ReadableStream<Uint8Array>;
92
+ declare type ReadableByteStream = ReadableStream<Uint8Array> & {
93
+ _readableStreamController: ReadableByteStreamController;
94
+ };
93
95
 
94
96
  /**
95
97
  * Allows control of a {@link ReadableStream | readable byte stream}'s state and internal queue.
@@ -173,7 +175,10 @@ export declare class ReadableStream<R = any> {
173
175
  *
174
176
  * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
175
177
  */
176
- pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
178
+ pipeThrough<RS extends ReadableStream>(transform: {
179
+ readable: RS;
180
+ writable: WritableStream<R>;
181
+ }, options?: StreamPipeOptions): RS;
177
182
  /**
178
183
  * Pipes this readable stream to a given writable stream. The way in which the piping process behaves under
179
184
  * various error conditions can be customized with a number of passed options. It returns a promise that fulfills
@@ -218,7 +223,7 @@ export declare class ReadableStream<R = any> {
218
223
  * @public
219
224
  */
220
225
  export declare interface ReadableStreamAsyncIterator<R> extends AsyncIterator<R> {
221
- next(): Promise<IteratorResult<R>>;
226
+ next(): Promise<IteratorResult<R, undefined>>;
222
227
  return(value?: any): Promise<IteratorResult<any>>;
223
228
  }
224
229
 
@@ -233,7 +238,7 @@ export declare class ReadableStreamBYOBReader {
233
238
  * Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
234
239
  * the reader's lock is released before the stream finishes closing.
235
240
  */
236
- readonly closed: Promise<void>;
241
+ readonly closed: Promise<undefined>;
237
242
  /**
238
243
  * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
239
244
  */
@@ -262,8 +267,11 @@ export declare class ReadableStreamBYOBReader {
262
267
  * @public
263
268
  */
264
269
  export declare type ReadableStreamBYOBReadResult<T extends ArrayBufferView> = {
265
- done: boolean;
270
+ done: false;
266
271
  value: T;
272
+ } | {
273
+ done: true;
274
+ value: T | undefined;
267
275
  };
268
276
 
269
277
  /**
@@ -333,7 +341,7 @@ export declare class ReadableStreamDefaultReader<R = any> {
333
341
  * Returns a promise that will be fulfilled when the stream becomes closed,
334
342
  * or rejected if the stream ever errors or the reader's lock is released before the stream finishes closing.
335
343
  */
336
- readonly closed: Promise<void>;
344
+ readonly closed: Promise<undefined>;
337
345
  /**
338
346
  * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
339
347
  */
@@ -366,7 +374,7 @@ export declare type ReadableStreamDefaultReadResult<T> = {
366
374
  value: T;
367
375
  } | {
368
376
  done: true;
369
- value: undefined;
377
+ value?: undefined;
370
378
  };
371
379
 
372
380
  /**
@@ -658,7 +666,7 @@ export declare class WritableStream<W = any> {
658
666
  * successfully closes, or rejects if an error is encountered during this process. Additionally, it will reject with
659
667
  * a `TypeError` (without attempting to cancel the stream) if the stream is currently locked.
660
668
  */
661
- close(): Promise<void>;
669
+ close(): Promise<undefined>;
662
670
  /**
663
671
  * Creates a {@link WritableStreamDefaultWriter | writer} and locks the stream to the new writer. While the stream
664
672
  * is locked, no other writer can be acquired until this one is released.
@@ -677,6 +685,14 @@ export declare class WritableStream<W = any> {
677
685
  */
678
686
  export declare class WritableStreamDefaultController<W = any> {
679
687
  private constructor();
688
+ /**
689
+ * The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted.
690
+ */
691
+ readonly abortReason: any;
692
+ /**
693
+ * An `AbortSignal` that can be used to abort the pending write or close operation when the stream is aborted.
694
+ */
695
+ readonly signal: AbortSignal;
680
696
  /**
681
697
  * Closes the controlled writable stream, making all future interactions with it fail with the given error `e`.
682
698
  *
@@ -698,7 +714,7 @@ export declare class WritableStreamDefaultWriter<W = any> {
698
714
  * Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
699
715
  * the writer’s lock is released before the stream finishes closing.
700
716
  */
701
- readonly closed: Promise<void>;
717
+ readonly closed: Promise<undefined>;
702
718
  /**
703
719
  * Returns the desired size to fill the stream’s internal queue. It can be negative, if the queue is over-full.
704
720
  * A producer can use this information to determine the right amount of data to write.
@@ -716,7 +732,7 @@ export declare class WritableStreamDefaultWriter<W = any> {
716
732
  * If the stream becomes errored or aborted, or the writer’s lock is released, the returned promise will become
717
733
  * rejected.
718
734
  */
719
- readonly ready: Promise<void>;
735
+ readonly ready: Promise<undefined>;
720
736
  /**
721
737
  * If the reader is active, behaves the same as {@link WritableStream.abort | stream.abort(reason)}.
722
738
  */
@@ -89,7 +89,9 @@ export declare interface QueuingStrategyInit {
89
89
 
90
90
  declare type QueuingStrategySizeCallback<T = any> = (chunk: T) => number;
91
91
 
92
- declare type ReadableByteStream = ReadableStream<Uint8Array>;
92
+ declare type ReadableByteStream = ReadableStream<Uint8Array> & {
93
+ _readableStreamController: ReadableByteStreamController;
94
+ };
93
95
 
94
96
  /**
95
97
  * Allows control of a {@link ReadableStream | readable byte stream}'s state and internal queue.
@@ -173,7 +175,10 @@ export declare class ReadableStream<R = any> {
173
175
  *
174
176
  * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
175
177
  */
176
- pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
178
+ pipeThrough<RS extends ReadableStream>(transform: {
179
+ readable: RS;
180
+ writable: WritableStream<R>;
181
+ }, options?: StreamPipeOptions): RS;
177
182
  /**
178
183
  * Pipes this readable stream to a given writable stream. The way in which the piping process behaves under
179
184
  * various error conditions can be customized with a number of passed options. It returns a promise that fulfills
@@ -218,7 +223,7 @@ export declare class ReadableStream<R = any> {
218
223
  * @public
219
224
  */
220
225
  export declare interface ReadableStreamAsyncIterator<R> extends AsyncIterator<R> {
221
- next(): Promise<IteratorResult<R>>;
226
+ next(): Promise<IteratorResult<R, undefined>>;
222
227
  return(value?: any): Promise<IteratorResult<any>>;
223
228
  }
224
229
 
@@ -233,7 +238,7 @@ export declare class ReadableStreamBYOBReader {
233
238
  * Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
234
239
  * the reader's lock is released before the stream finishes closing.
235
240
  */
236
- get closed(): Promise<void>;
241
+ get closed(): Promise<undefined>;
237
242
  /**
238
243
  * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
239
244
  */
@@ -262,8 +267,11 @@ export declare class ReadableStreamBYOBReader {
262
267
  * @public
263
268
  */
264
269
  export declare type ReadableStreamBYOBReadResult<T extends ArrayBufferView> = {
265
- done: boolean;
270
+ done: false;
266
271
  value: T;
272
+ } | {
273
+ done: true;
274
+ value: T | undefined;
267
275
  };
268
276
 
269
277
  /**
@@ -333,7 +341,7 @@ export declare class ReadableStreamDefaultReader<R = any> {
333
341
  * Returns a promise that will be fulfilled when the stream becomes closed,
334
342
  * or rejected if the stream ever errors or the reader's lock is released before the stream finishes closing.
335
343
  */
336
- get closed(): Promise<void>;
344
+ get closed(): Promise<undefined>;
337
345
  /**
338
346
  * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
339
347
  */
@@ -366,7 +374,7 @@ export declare type ReadableStreamDefaultReadResult<T> = {
366
374
  value: T;
367
375
  } | {
368
376
  done: true;
369
- value: undefined;
377
+ value?: undefined;
370
378
  };
371
379
 
372
380
  /**
@@ -658,7 +666,7 @@ export declare class WritableStream<W = any> {
658
666
  * successfully closes, or rejects if an error is encountered during this process. Additionally, it will reject with
659
667
  * a `TypeError` (without attempting to cancel the stream) if the stream is currently locked.
660
668
  */
661
- close(): Promise<void>;
669
+ close(): Promise<undefined>;
662
670
  /**
663
671
  * Creates a {@link WritableStreamDefaultWriter | writer} and locks the stream to the new writer. While the stream
664
672
  * is locked, no other writer can be acquired until this one is released.
@@ -677,6 +685,14 @@ export declare class WritableStream<W = any> {
677
685
  */
678
686
  export declare class WritableStreamDefaultController<W = any> {
679
687
  private constructor();
688
+ /**
689
+ * The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted.
690
+ */
691
+ get abortReason(): any;
692
+ /**
693
+ * An `AbortSignal` that can be used to abort the pending write or close operation when the stream is aborted.
694
+ */
695
+ get signal(): AbortSignal;
680
696
  /**
681
697
  * Closes the controlled writable stream, making all future interactions with it fail with the given error `e`.
682
698
  *
@@ -698,7 +714,7 @@ export declare class WritableStreamDefaultWriter<W = any> {
698
714
  * Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
699
715
  * the writer’s lock is released before the stream finishes closing.
700
716
  */
701
- get closed(): Promise<void>;
717
+ get closed(): Promise<undefined>;
702
718
  /**
703
719
  * Returns the desired size to fill the stream’s internal queue. It can be negative, if the queue is over-full.
704
720
  * A producer can use this information to determine the right amount of data to write.
@@ -716,7 +732,7 @@ export declare class WritableStreamDefaultWriter<W = any> {
716
732
  * If the stream becomes errored or aborted, or the writer’s lock is released, the returned promise will become
717
733
  * rejected.
718
734
  */
719
- get ready(): Promise<void>;
735
+ get ready(): Promise<undefined>;
720
736
  /**
721
737
  * If the reader is active, behaves the same as {@link WritableStream.abort | stream.abort(reason)}.
722
738
  */
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.9.2"
8
+ "packageVersion": "7.13.4"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-streams-polyfill",
3
- "version": "3.0.1",
3
+ "version": "3.1.1",
4
4
  "description": "Web Streams, based on the WHATWG spec reference implementation",
5
5
  "main": "dist/polyfill",
6
6
  "browser": "dist/polyfill.min.js",
@@ -54,23 +54,23 @@
54
54
  },
55
55
  "homepage": "https://github.com/MattiasBuelens/web-streams-polyfill#readme",
56
56
  "devDependencies": {
57
- "@microsoft/api-extractor": "^7.9.2",
57
+ "@microsoft/api-extractor": "^7.13.4",
58
58
  "@rollup/plugin-inject": "^4.0.2",
59
- "@rollup/plugin-replace": "^2.3.3",
59
+ "@rollup/plugin-replace": "^2.4.2",
60
60
  "@rollup/plugin-strip": "^2.0.0",
61
- "@rollup/plugin-typescript": "^5.0.2",
62
- "@types/node": "^12.12.50",
63
- "@typescript-eslint/eslint-plugin": "^3.6.1",
64
- "@typescript-eslint/parser": "^3.6.1",
65
- "@ungap/promise-all-settled": "^1.1.0",
66
- "eslint": "^7.5.0",
67
- "jasmine": "^3.5.0",
61
+ "@rollup/plugin-typescript": "^8.2.1",
62
+ "@types/node": "^14.14.37",
63
+ "@typescript-eslint/eslint-plugin": "^4.21.0",
64
+ "@typescript-eslint/parser": "^4.21.0",
65
+ "@ungap/promise-all-settled": "^1.1.2",
66
+ "eslint": "^7.23.0",
67
+ "jasmine": "^3.7.0",
68
68
  "micromatch": "^4.0.2",
69
- "rollup": "^2.22.1",
70
- "rollup-plugin-terser": "^6.1.0",
71
- "ts-morph": "^7.1.2",
72
- "tslib": "^2.0.0",
73
- "typescript": "^3.9.7",
74
- "wpt-runner": "^3.2.0"
69
+ "rollup": "^2.44.0",
70
+ "rollup-plugin-terser": "^7.0.2",
71
+ "ts-morph": "^10.0.2",
72
+ "tslib": "^2.2.0",
73
+ "typescript": "^4.2.4",
74
+ "wpt-runner": "^3.2.1"
75
75
  }
76
76
  }