web-streams-polyfill 3.1.0 → 3.2.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.
@@ -146,7 +146,7 @@ export declare class ReadableStream<R = any> {
146
146
  * The supplied `reason` argument will be given to the underlying source's {@link UnderlyingSource.cancel | cancel()}
147
147
  * method, which might or might not use it.
148
148
  */
149
- cancel(reason?: any): Promise<undefined>;
149
+ cancel(reason?: any): Promise<void>;
150
150
  /**
151
151
  * Creates a {@link ReadableStreamBYOBReader} and locks the stream to the new reader.
152
152
  *
@@ -175,7 +175,10 @@ export declare class ReadableStream<R = any> {
175
175
  *
176
176
  * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
177
177
  */
178
- 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;
179
182
  /**
180
183
  * Pipes this readable stream to a given writable stream. The way in which the piping process behaves under
181
184
  * various error conditions can be customized with a number of passed options. It returns a promise that fulfills
@@ -183,7 +186,7 @@ export declare class ReadableStream<R = any> {
183
186
  *
184
187
  * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
185
188
  */
186
- pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<undefined>;
189
+ pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
187
190
  /**
188
191
  * Tees this readable stream, returning a two-element array containing the two resulting branches as
189
192
  * new {@link ReadableStream} instances.
@@ -220,7 +223,7 @@ export declare class ReadableStream<R = any> {
220
223
  * @public
221
224
  */
222
225
  export declare interface ReadableStreamAsyncIterator<R> extends AsyncIterator<R> {
223
- next(): Promise<IteratorResult<R>>;
226
+ next(): Promise<IteratorResult<R, undefined>>;
224
227
  return(value?: any): Promise<IteratorResult<any>>;
225
228
  }
226
229
 
@@ -239,7 +242,7 @@ export declare class ReadableStreamBYOBReader {
239
242
  /**
240
243
  * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
241
244
  */
242
- cancel(reason?: any): Promise<undefined>;
245
+ cancel(reason?: any): Promise<void>;
243
246
  /**
244
247
  * Attempts to reads bytes into view, and returns a promise resolved with the result.
245
248
  *
@@ -342,7 +345,7 @@ export declare class ReadableStreamDefaultReader<R = any> {
342
345
  /**
343
346
  * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
344
347
  */
345
- cancel(reason?: any): Promise<undefined>;
348
+ cancel(reason?: any): Promise<void>;
346
349
  /**
347
350
  * Returns a promise that allows access to the next chunk from the stream's internal queue, if available.
348
351
  *
@@ -371,7 +374,7 @@ export declare type ReadableStreamDefaultReadResult<T> = {
371
374
  value: T;
372
375
  } | {
373
376
  done: true;
374
- value: undefined;
377
+ value?: undefined;
375
378
  };
376
379
 
377
380
  /**
@@ -654,7 +657,7 @@ export declare class WritableStream<W = any> {
654
657
  * that there was an error doing so. Additionally, it will reject with a `TypeError` (without attempting to cancel
655
658
  * the stream) if the stream is currently locked.
656
659
  */
657
- abort(reason?: any): Promise<undefined>;
660
+ abort(reason?: any): Promise<void>;
658
661
  /**
659
662
  * Closes the stream. The underlying sink will finish processing any previously-written chunks, before invoking its
660
663
  * close behavior. During this time any further attempts to write will fail (without erroring the stream).
@@ -684,6 +687,10 @@ export declare class WritableStreamDefaultController<W = any> {
684
687
  private constructor();
685
688
  /**
686
689
  * The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted.
690
+ *
691
+ * @deprecated
692
+ * This property has been removed from the specification, see https://github.com/whatwg/streams/pull/1177.
693
+ * Use {@link WritableStreamDefaultController.signal}'s `reason` instead.
687
694
  */
688
695
  readonly abortReason: any;
689
696
  /**
@@ -733,11 +740,11 @@ export declare class WritableStreamDefaultWriter<W = any> {
733
740
  /**
734
741
  * If the reader is active, behaves the same as {@link WritableStream.abort | stream.abort(reason)}.
735
742
  */
736
- abort(reason?: any): Promise<undefined>;
743
+ abort(reason?: any): Promise<void>;
737
744
  /**
738
745
  * If the reader is active, behaves the same as {@link WritableStream.close | stream.close()}.
739
746
  */
740
- close(): Promise<undefined>;
747
+ close(): Promise<void>;
741
748
  /**
742
749
  * Releases the writer’s lock on the corresponding stream. After the lock is released, the writer is no longer active.
743
750
  * If the associated stream is errored when the lock is released, the writer will appear errored in the same way from
@@ -758,7 +765,7 @@ export declare class WritableStreamDefaultWriter<W = any> {
758
765
  * Note that what "success" means is up to the underlying sink; it might indicate simply that the chunk has been
759
766
  * accepted, and not necessarily that it is safely saved to its ultimate destination.
760
767
  */
761
- write(chunk: W): Promise<undefined>;
768
+ write(chunk: W): Promise<void>;
762
769
  }
763
770
 
764
771
  export { }
@@ -146,7 +146,7 @@ export declare class ReadableStream<R = any> {
146
146
  * The supplied `reason` argument will be given to the underlying source's {@link UnderlyingSource.cancel | cancel()}
147
147
  * method, which might or might not use it.
148
148
  */
149
- cancel(reason?: any): Promise<undefined>;
149
+ cancel(reason?: any): Promise<void>;
150
150
  /**
151
151
  * Creates a {@link ReadableStreamBYOBReader} and locks the stream to the new reader.
152
152
  *
@@ -175,7 +175,10 @@ export declare class ReadableStream<R = any> {
175
175
  *
176
176
  * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
177
177
  */
178
- 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;
179
182
  /**
180
183
  * Pipes this readable stream to a given writable stream. The way in which the piping process behaves under
181
184
  * various error conditions can be customized with a number of passed options. It returns a promise that fulfills
@@ -183,7 +186,7 @@ export declare class ReadableStream<R = any> {
183
186
  *
184
187
  * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
185
188
  */
186
- pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<undefined>;
189
+ pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
187
190
  /**
188
191
  * Tees this readable stream, returning a two-element array containing the two resulting branches as
189
192
  * new {@link ReadableStream} instances.
@@ -220,7 +223,7 @@ export declare class ReadableStream<R = any> {
220
223
  * @public
221
224
  */
222
225
  export declare interface ReadableStreamAsyncIterator<R> extends AsyncIterator<R> {
223
- next(): Promise<IteratorResult<R>>;
226
+ next(): Promise<IteratorResult<R, undefined>>;
224
227
  return(value?: any): Promise<IteratorResult<any>>;
225
228
  }
226
229
 
@@ -239,7 +242,7 @@ export declare class ReadableStreamBYOBReader {
239
242
  /**
240
243
  * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
241
244
  */
242
- cancel(reason?: any): Promise<undefined>;
245
+ cancel(reason?: any): Promise<void>;
243
246
  /**
244
247
  * Attempts to reads bytes into view, and returns a promise resolved with the result.
245
248
  *
@@ -342,7 +345,7 @@ export declare class ReadableStreamDefaultReader<R = any> {
342
345
  /**
343
346
  * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
344
347
  */
345
- cancel(reason?: any): Promise<undefined>;
348
+ cancel(reason?: any): Promise<void>;
346
349
  /**
347
350
  * Returns a promise that allows access to the next chunk from the stream's internal queue, if available.
348
351
  *
@@ -371,7 +374,7 @@ export declare type ReadableStreamDefaultReadResult<T> = {
371
374
  value: T;
372
375
  } | {
373
376
  done: true;
374
- value: undefined;
377
+ value?: undefined;
375
378
  };
376
379
 
377
380
  /**
@@ -654,7 +657,7 @@ export declare class WritableStream<W = any> {
654
657
  * that there was an error doing so. Additionally, it will reject with a `TypeError` (without attempting to cancel
655
658
  * the stream) if the stream is currently locked.
656
659
  */
657
- abort(reason?: any): Promise<undefined>;
660
+ abort(reason?: any): Promise<void>;
658
661
  /**
659
662
  * Closes the stream. The underlying sink will finish processing any previously-written chunks, before invoking its
660
663
  * close behavior. During this time any further attempts to write will fail (without erroring the stream).
@@ -684,6 +687,10 @@ export declare class WritableStreamDefaultController<W = any> {
684
687
  private constructor();
685
688
  /**
686
689
  * The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted.
690
+ *
691
+ * @deprecated
692
+ * This property has been removed from the specification, see https://github.com/whatwg/streams/pull/1177.
693
+ * Use {@link WritableStreamDefaultController.signal}'s `reason` instead.
687
694
  */
688
695
  get abortReason(): any;
689
696
  /**
@@ -733,11 +740,11 @@ export declare class WritableStreamDefaultWriter<W = any> {
733
740
  /**
734
741
  * If the reader is active, behaves the same as {@link WritableStream.abort | stream.abort(reason)}.
735
742
  */
736
- abort(reason?: any): Promise<undefined>;
743
+ abort(reason?: any): Promise<void>;
737
744
  /**
738
745
  * If the reader is active, behaves the same as {@link WritableStream.close | stream.close()}.
739
746
  */
740
- close(): Promise<undefined>;
747
+ close(): Promise<void>;
741
748
  /**
742
749
  * Releases the writer’s lock on the corresponding stream. After the lock is released, the writer is no longer active.
743
750
  * If the associated stream is errored when the lock is released, the writer will appear errored in the same way from
@@ -758,7 +765,7 @@ export declare class WritableStreamDefaultWriter<W = any> {
758
765
  * Note that what "success" means is up to the underlying sink; it might indicate simply that the chunk has been
759
766
  * accepted, and not necessarily that it is safely saved to its ultimate destination.
760
767
  */
761
- write(chunk: W): Promise<undefined>;
768
+ write(chunk: W): Promise<void>;
762
769
  }
763
770
 
764
771
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-streams-polyfill",
3
- "version": "3.1.0",
3
+ "version": "3.2.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",
package/CHANGELOG.md DELETED
@@ -1,123 +0,0 @@
1
- # Changelog
2
-
3
- > **Tags:**
4
- > - 💥 Breaking Change
5
- > - 👓 Spec Compliance
6
- > - 🚀 New Feature
7
- > - 🐛 Bug Fix
8
- > - 📝 Documentation
9
- > - 🏠 Internal
10
- > - 💅 Polish
11
-
12
- ## v3.1.0 (2021-07-21)
13
-
14
- * 🚀 Calling `ReadableStream.tee()` on a readable byte stream now returns two readable byte streams. ([#81](https://github.com/MattiasBuelens/web-streams-polyfill/pull/81))
15
- * 🚀 Add `WritableStreamDefaultController.signal` and `.abortReason`. ([#81](https://github.com/MattiasBuelens/web-streams-polyfill/pull/81))
16
- * `.signal` requires a global `AbortController` constructor to be available. If necessary, use a polyfill.
17
- * 🐛 Make sure streams created with a different version of the polyfill do not pass the brand checks. ([#75](https://github.com/MattiasBuelens/web-streams-polyfill/issues/75), [#77](https://github.com/MattiasBuelens/web-streams-polyfill/pull/77))
18
- * 👓 Align with [spec version `cada812`](https://github.com/whatwg/streams/tree/cada8129edcc4803b2878a7a3f5e1d8325dc0c23/) ([#79](https://github.com/MattiasBuelens/web-streams-polyfill/pull/79), [#81](https://github.com/MattiasBuelens/web-streams-polyfill/pull/81))
19
-
20
- ## v3.0.3 (2021-04-09)
21
-
22
- * 💅 Change `Promise<void>` to `Promise<undefined>` in TypeScript type definitions ([#72](https://github.com/MattiasBuelens/web-streams-polyfill/pull/72))
23
- * 🐛 Fix `ReadableStream.tee()` resolving its `cancel()` promise too early ([#73](https://github.com/MattiasBuelens/web-streams-polyfill/pull/73))
24
- * 👓 Align with [spec version `6762cdb`](https://github.com/whatwg/streams/tree/6762cdb4c6421cfa0da1d834d5a14fdd7326aaa5/) ([#73](https://github.com/MattiasBuelens/web-streams-polyfill/pull/73))
25
-
26
- ## v3.0.2 (2021-02-10)
27
-
28
- * 👓 Align with [spec version `200c971`](https://github.com/whatwg/streams/tree/200c971563b1a695fce3eebe6dab45c348ff0ac0/) ([#69](https://github.com/MattiasBuelens/web-streams-polyfill/pull/69))
29
-
30
- ## v3.0.1 (2020-11-12)
31
-
32
- * 📝 Add documentation to type definitions ([#62](https://github.com/MattiasBuelens/web-streams-polyfill/pull/62))
33
- * 👓 Align with [spec version `6cd5e81`](https://github.com/whatwg/streams/tree/6cd5e81f6191fed9e7d99ee73d4941e3060311ce/) ([#63](https://github.com/MattiasBuelens/web-streams-polyfill/pull/63))
34
- * 🐛 Fix an issue where the polyfill could throw an error when resolving/rejecting `reader.closed` when it was already resolved/rejected ([#66](https://github.com/MattiasBuelens/web-streams-polyfill/issues/66), [#67](https://github.com/MattiasBuelens/web-streams-polyfill/pull/67))
35
-
36
- ## v3.0.0 (2020-07-20)
37
-
38
- * 💥 Align with [spec version `62fe4c8`](https://github.com/whatwg/streams/tree/62fe4c8c0df34cec4ff28db9bfa69aec6c65e38d/) ([#52](https://github.com/MattiasBuelens/web-streams-polyfill/pull/52), [#57](https://github.com/MattiasBuelens/web-streams-polyfill/pull/57), [#59](https://github.com/MattiasBuelens/web-streams-polyfill/pull/59))
39
- This includes the following **breaking changes**:
40
- * All classes are now exposed globally. Concretely, this adds the following classes:
41
- * `ReadableStreamDefaultController`
42
- * `ReadableByteStreamController`
43
- * `ReadableStreamBYOBRequest`
44
- * `ReadableStreamDefaultReader`
45
- * `ReadableStreamBYOBReader`
46
- * `WritableStreamDefaultController`
47
- * `WritableStreamDefaultWriter`
48
- * `TransformStreamDefaultController`
49
- * `ReadableStream.getIterator()` is renamed to `ReadableStream.values()`
50
- * `ReadableByteStreamController.byobRequest` can be `null` (instead of `undefined`) if there is no current BYOB request.
51
- * `ReadableStreamBYOBRequest.view` can be `null` (instead of `undefined`) if the BYOB request has already been responded to.
52
- * Constructors and methods have stricter type checking for object arguments. For example, `new ReadableStream(null)` would previously behave like `new ReadableStream({})`, but now it throws a `TypeError` instead.
53
- * Some constructors and methods may throw slightly different errors when given invalid arguments.
54
- * Various byte-stream-related APIs now prohibit zero-length views or buffers.
55
- * The async iterator of a `ReadableStream` now behaves more like an async generator, e.g. returning promises fulfilled with `{ value: undefined, done: true }` after `return()`ing the iterator, instead of returning a rejected promise.
56
- * 💥 Updated TypeScript types to align with new specification ([#60](https://github.com/MattiasBuelens/web-streams-polyfill/pull/60))
57
- While these are _technically_ breaking changes, you should only be affected if you manually reference these types from your code.
58
- * `PipeOptions` is renamed to `StreamPipeOptions`
59
- * `ReadResult` is replaced by `ReadableStreamDefaultReadResult` and `ReadableStreamBYOBReadResult`
60
- * `ReadableStreamDefaultControllerCallback` is replaced by `UnderlyingSourceStartCallback` and `UnderlyingSourcePullCallback`
61
- * `ReadableByteStreamControllerCallback` is replaced by `UnderlyingByteSourceStartCallback` and `UnderlyingByteSourcePullCallback`
62
- * `ReadableStreamErrorCallback` is renamed to `UnderlyingSourceCancelCallback`
63
- * `WritableStreamDefaultControllerStartCallback` is renamed to `UnderlyingSinkStartCallback`
64
- * `WritableStreamDefaultControllerWriteCallback` is renamed to `UnderlyingSinkWriteCallback`
65
- * `WritableStreamDefaultControllerCloseCallback` is renamed to `UnderlyingSinkCloseCallback`
66
- * `WritableStreamErrorCallback` is renamed to `UnderlyingSinkAbortCallback`
67
- * `TransformStreamDefaultControllerCallback` is replaced by `TransformerStartCallback` and `TransformerFlushCallback`
68
- * `TransformStreamDefaultControllerTransformCallback` is renamed to `TransformerTransformCallback`
69
-
70
- ## v2.1.1 (2020-04-11)
71
-
72
- * 💅 Improve `ReadResult` in TypeScript type definitions. ([759506e](https://github.com/MattiasBuelens/web-streams-polyfill/commit/759506e00e55289ae6f92f30922b8855fcddd9ab), [#49](https://github.com/MattiasBuelens/web-streams-polyfill/pull/49))
73
-
74
- ## v2.1.0 (2020-02-23)
75
-
76
- * 👓 Align with [spec version `ed00d2f`](https://github.com/whatwg/streams/tree/ed00d2fe2d53ac5ad9ff8e727c7ef0a68f424074/) ([#43](https://github.com/MattiasBuelens/web-streams-polyfill/issues/43), [#44](https://github.com/MattiasBuelens/web-streams-polyfill/pull/44))
77
- * 🏠 Down-level type definitions for older TypeScript versions. ([#41](https://github.com/MattiasBuelens/web-streams-polyfill/pull/41))
78
-
79
- ## v2.0.6 (2019-11-08)
80
-
81
- * 🐛 Fix type definitions to be compatible with TypeScript 3.3 and lower. ([#39](https://github.com/MattiasBuelens/web-streams-polyfill/issues/39), [#40](https://github.com/MattiasBuelens/web-streams-polyfill/pull/40))
82
-
83
- ## v2.0.5 (2019-10-08)
84
-
85
- * 👓 Align with [spec version `ae5e0cb`](https://github.com/whatwg/streams/tree/ae5e0cb41e9f72cdd97f3a6d47bc674c1f4049d1/) ([#33](https://github.com/MattiasBuelens/web-streams-polyfill/pull/33))
86
- * 🐛 Fix support for non-browser environments, such as Node.
87
- * Accept polyfilled `AbortSignal`s. ([#36](https://github.com/MattiasBuelens/web-streams-polyfill/pull/36))
88
- * Polyfill `DOMException` if necessary. ([#37](https://github.com/MattiasBuelens/web-streams-polyfill/pull/37))
89
-
90
- ## v2.0.4 (2019-08-01)
91
-
92
- * 🐛 Fix pipe not aborting when both `preventAbort` and `preventCancel` are set ([#31](https://github.com/MattiasBuelens/web-streams-polyfill/pull/31))
93
- * 👓 Align with [spec version `e4d3b1a`](https://github.com/whatwg/streams/tree/e4d3b1a826e34d27a7cb5485a1cc4b078608c9ec/) ([#31](https://github.com/MattiasBuelens/web-streams-polyfill/pull/31))
94
-
95
- ## v2.0.3 (2019-04-04)
96
-
97
- * 👓 Align with [spec version `6f94580`](https://github.com/whatwg/streams/tree/6f94580f6731d1e017c516af097d47c45aad1f56/) ([#21](https://github.com/MattiasBuelens/web-streams-polyfill/pull/21))
98
- * 🏠 Run web platform tests on ES5 variant ([#19](https://github.com/MattiasBuelens/web-streams-polyfill/pull/19))
99
-
100
- ## v2.0.2 (2019-03-17)
101
-
102
- * 💅 Improve performance of `reader.read()` and `writer.write()` ([#17](https://github.com/MattiasBuelens/web-streams-polyfill/pull/17), [#18](https://github.com/MattiasBuelens/web-streams-polyfill/pull/18))
103
-
104
- ## v2.0.1 (2019-03-16)
105
-
106
- * 🐛 Fix performance issue with large queues ([#15](https://github.com/MattiasBuelens/web-streams-polyfill/pull/15), [#16](https://github.com/MattiasBuelens/web-streams-polyfill/pull/16))
107
-
108
- ## v2.0.0 (2019-03-10)
109
-
110
- * 💥 Ownership change: [@mattiasbuelens/web-streams-polyfill](https://www.npmjs.com/package/@mattiasbuelens/web-streams-polyfill/v/0.3.2) has been republished as [web-streams-polyfill](https://www.npmjs.com/package/web-streams-polyfill).
111
- For the full list of changes between web-streams-polyfill v1.3.2 and this version, [visit the fork's changelog](https://github.com/MattiasBuelens/web-streams-polyfill/blob/v0.3.2/CHANGELOG.md).
112
-
113
- * 💥 CommonJS entry points have been moved to `dist/`:
114
- * `index.js` ➡ `dist/polyfill.js`
115
- * `index.es6.js` ➡ `dist/polyfill.es6.js`
116
-
117
- However, we recommend migrating to a [variant sub-package](https://github.com/MattiasBuelens/web-streams-polyfill#usage) instead:
118
- * `require('web-streams-polyfill/index.js')` ➡ `require('web-streams-polyfill')`
119
- * `require('web-streams-polyfill/index.es6.js')` ➡ `require('web-streams-polyfill/es6')`
120
-
121
- * 👓 Align with [spec version `2c8f35e`](https://github.com/whatwg/streams/tree/2c8f35ed23451ffc9b32ec37b56def4a5349abb1/)
122
-
123
- * 🏠 Code moved from [creatorrr/web-streams-polyfill](https://github.com/creatorrr/web-streams-polyfill) to [MattiasBuelens/web-streams-polyfill](https://github.com/MattiasBuelens/web-streams-polyfill)