web-streams-polyfill 3.0.2 → 3.0.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.
package/CHANGELOG.md CHANGED
@@ -9,7 +9,13 @@
9
9
  > - 🏠 Internal
10
10
  > - 💅 Polish
11
11
 
12
- ## v3.0.1 (2020-02-10)
12
+ ## v3.0.3 (2020-04-09)
13
+
14
+ * 💅 Change `Promise<void>` to `Promise<undefined>` in TypeScript type definitions ([#72](https://github.com/MattiasBuelens/web-streams-polyfill/pull/72))
15
+ * 🐛 Fix `ReadableStream.tee()` resolving its `cancel()` promise too early ([#73](https://github.com/MattiasBuelens/web-streams-polyfill/pull/73))
16
+ * 👓 Align with [spec version `6762cdb`](https://github.com/whatwg/streams/tree/6762cdb4c6421cfa0da1d834d5a14fdd7326aaa5/) ([#73](https://github.com/MattiasBuelens/web-streams-polyfill/pull/73))
17
+
18
+ ## v3.0.2 (2020-02-10)
13
19
 
14
20
  * 👓 Align with [spec version `200c971`](https://github.com/whatwg/streams/tree/200c971563b1a695fce3eebe6dab45c348ff0ac0/) ([#69](https://github.com/MattiasBuelens/web-streams-polyfill/pull/69))
15
21
 
package/README.md CHANGED
@@ -66,7 +66,7 @@ The `polyfill/es2018` and `ponyfill/es2018` variants work in any ES2018-compatib
66
66
 
67
67
  ### Compliance
68
68
 
69
- The polyfill implements [version `200c971` (8 Feb 2021)][spec-snapshot] of the streams specification.
69
+ The polyfill implements [version `6762cdb` (31 Mar 2021)][spec-snapshot] of the streams specification.
70
70
 
71
71
  The polyfill is tested against the same [web platform tests][wpt] that are used by browsers to test their native implementations.
72
72
  The polyfill aims to pass all tests, although it allows some exceptions for practical reasons:
@@ -99,12 +99,12 @@ Thanks to these people for their work on [the original polyfill][creatorrr-polyf
99
99
  [promise-support]: https://kangax.github.io/compat-table/es6/#test-Promise
100
100
  [promise-polyfill]: https://www.npmjs.com/package/promise-polyfill
101
101
  [rs-asynciterator]: https://streams.spec.whatwg.org/#rs-asynciterator
102
- [spec-snapshot]: https://streams.spec.whatwg.org/commit-snapshots/200c971563b1a695fce3eebe6dab45c348ff0ac0/
103
- [wpt]: https://github.com/web-platform-tests/wpt/tree/7e94a4bcb5bd6808e08ed8db46fa63751543db52/streams
104
- [wpt-bad-buffers]: https://github.com/web-platform-tests/wpt/blob/7e94a4bcb5bd6808e08ed8db46fa63751543db52/streams/readable-byte-streams/bad-buffers-and-views.any.js
102
+ [spec-snapshot]: https://streams.spec.whatwg.org/commit-snapshots/6762cdb4c6421cfa0da1d834d5a14fdd7326aaa5/
103
+ [wpt]: https://github.com/web-platform-tests/wpt/tree/1bdb43faa7434d36645ab5c64e754b5caefbc9d2/streams
104
+ [wpt-bad-buffers]: https://github.com/web-platform-tests/wpt/blob/1bdb43faa7434d36645ab5c64e754b5caefbc9d2/streams/readable-byte-streams/bad-buffers-and-views.any.js
105
105
  [proposal-arraybuffer-transfer]: https://github.com/domenic/proposal-arraybuffer-transfer
106
- [ref-impl-transferarraybuffer]: https://github.com/whatwg/streams/blob/200c971563b1a695fce3eebe6dab45c348ff0ac0/reference-implementation/lib/abstract-ops/ecmascript.js#L16
106
+ [ref-impl-transferarraybuffer]: https://github.com/whatwg/streams/blob/6762cdb4c6421cfa0da1d834d5a14fdd7326aaa5/reference-implementation/lib/abstract-ops/ecmascript.js#L16
107
107
  [issue-3]: https://github.com/MattiasBuelens/web-streams-polyfill/issues/3
108
- [wpt-async-iterator-prototype]: https://github.com/web-platform-tests/wpt/blob/7e94a4bcb5bd6808e08ed8db46fa63751543db52/streams/readable-streams/async-iterator.any.js#L24
108
+ [wpt-async-iterator-prototype]: https://github.com/web-platform-tests/wpt/blob/1bdb43faa7434d36645ab5c64e754b5caefbc9d2/streams/readable-streams/async-iterator.any.js#L24
109
109
  [stub-async-iterator-prototype]: https://github.com/MattiasBuelens/web-streams-polyfill/blob/v2.0.0/src/target/es5/stub/async-iterator-prototype.ts
110
110
  [creatorrr-polyfill]: https://github.com/creatorrr/web-streams-polyfill
@@ -1,10 +1,10 @@
1
1
  /**
2
- * web-streams-polyfill v3.0.2
2
+ * web-streams-polyfill v3.0.3
3
3
  */
4
4
  (function (global, factory) {
5
5
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
6
6
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
7
- (global = global || self, factory(global.WebStreamsPolyfill = {}));
7
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.WebStreamsPolyfill = {}));
8
8
  }(this, (function (exports) { 'use strict';
9
9
 
10
10
  /// <reference lib="es2015.symbol" />
@@ -14,7 +14,7 @@
14
14
 
15
15
  /// <reference lib="dom" />
16
16
  function noop() {
17
- // do nothing
17
+ return undefined;
18
18
  }
19
19
  function getGlobals() {
20
20
  if (typeof self !== 'undefined') {
@@ -33,7 +33,7 @@
33
33
  function typeIsObject(x) {
34
34
  return (typeof x === 'object' && x !== null) || typeof x === 'function';
35
35
  }
36
- const rethrowAssertionErrorRejection = noop;
36
+ const rethrowAssertionErrorRejection = noop;
37
37
 
38
38
  const originalPromise = Promise;
39
39
  const originalPromiseThen = Promise.prototype.then;
@@ -1582,7 +1582,7 @@
1582
1582
  */
1583
1583
  get locked() {
1584
1584
  if (!IsWritableStream(this)) {
1585
- throw streamBrandCheckException('locked');
1585
+ throw streamBrandCheckException$2('locked');
1586
1586
  }
1587
1587
  return IsWritableStreamLocked(this);
1588
1588
  }
@@ -1597,7 +1597,7 @@
1597
1597
  */
1598
1598
  abort(reason = undefined) {
1599
1599
  if (!IsWritableStream(this)) {
1600
- return promiseRejectedWith(streamBrandCheckException('abort'));
1600
+ return promiseRejectedWith(streamBrandCheckException$2('abort'));
1601
1601
  }
1602
1602
  if (IsWritableStreamLocked(this)) {
1603
1603
  return promiseRejectedWith(new TypeError('Cannot abort a stream that already has a writer'));
@@ -1614,7 +1614,7 @@
1614
1614
  */
1615
1615
  close() {
1616
1616
  if (!IsWritableStream(this)) {
1617
- return promiseRejectedWith(streamBrandCheckException('close'));
1617
+ return promiseRejectedWith(streamBrandCheckException$2('close'));
1618
1618
  }
1619
1619
  if (IsWritableStreamLocked(this)) {
1620
1620
  return promiseRejectedWith(new TypeError('Cannot close a stream that already has a writer'));
@@ -1634,7 +1634,7 @@
1634
1634
  */
1635
1635
  getWriter() {
1636
1636
  if (!IsWritableStream(this)) {
1637
- throw streamBrandCheckException('getWriter');
1637
+ throw streamBrandCheckException$2('getWriter');
1638
1638
  }
1639
1639
  return AcquireWritableStreamDefaultWriter(this);
1640
1640
  }
@@ -2345,7 +2345,7 @@
2345
2345
  WritableStreamStartErroring(stream, error);
2346
2346
  }
2347
2347
  // Helper functions for the WritableStream.
2348
- function streamBrandCheckException(name) {
2348
+ function streamBrandCheckException$2(name) {
2349
2349
  return new TypeError(`WritableStream.prototype.${name} can only be used on a WritableStream`);
2350
2350
  }
2351
2351
  // Helper functions for the WritableStreamDefaultWriter.
@@ -2463,6 +2463,7 @@
2463
2463
  }
2464
2464
  }
2465
2465
  function createDOMExceptionPolyfill() {
2466
+ // eslint-disable-next-line no-shadow
2466
2467
  const ctor = function DOMException(message, name) {
2467
2468
  this.message = message || '';
2468
2469
  this.name = name || 'Error';
@@ -2474,6 +2475,7 @@
2474
2475
  Object.defineProperty(ctor.prototype, 'constructor', { value: ctor, writable: true, configurable: true });
2475
2476
  return ctor;
2476
2477
  }
2478
+ // eslint-disable-next-line no-redeclare
2477
2479
  const DOMException$1 = isDOMExceptionConstructor(NativeDOMException) ? NativeDOMException : createDOMExceptionPolyfill();
2478
2480
 
2479
2481
  function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
@@ -2666,7 +2668,7 @@
2666
2668
  */
2667
2669
  get desiredSize() {
2668
2670
  if (!IsReadableStreamDefaultController(this)) {
2669
- throw defaultControllerBrandCheckException('desiredSize');
2671
+ throw defaultControllerBrandCheckException$1('desiredSize');
2670
2672
  }
2671
2673
  return ReadableStreamDefaultControllerGetDesiredSize(this);
2672
2674
  }
@@ -2676,7 +2678,7 @@
2676
2678
  */
2677
2679
  close() {
2678
2680
  if (!IsReadableStreamDefaultController(this)) {
2679
- throw defaultControllerBrandCheckException('close');
2681
+ throw defaultControllerBrandCheckException$1('close');
2680
2682
  }
2681
2683
  if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
2682
2684
  throw new TypeError('The stream is not in a state that permits close');
@@ -2685,7 +2687,7 @@
2685
2687
  }
2686
2688
  enqueue(chunk = undefined) {
2687
2689
  if (!IsReadableStreamDefaultController(this)) {
2688
- throw defaultControllerBrandCheckException('enqueue');
2690
+ throw defaultControllerBrandCheckException$1('enqueue');
2689
2691
  }
2690
2692
  if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
2691
2693
  throw new TypeError('The stream is not in a state that permits enqueue');
@@ -2697,7 +2699,7 @@
2697
2699
  */
2698
2700
  error(e = undefined) {
2699
2701
  if (!IsReadableStreamDefaultController(this)) {
2700
- throw defaultControllerBrandCheckException('error');
2702
+ throw defaultControllerBrandCheckException$1('error');
2701
2703
  }
2702
2704
  ReadableStreamDefaultControllerError(this, e);
2703
2705
  }
@@ -2904,7 +2906,7 @@
2904
2906
  SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
2905
2907
  }
2906
2908
  // Helper functions for the ReadableStreamDefaultController.
2907
- function defaultControllerBrandCheckException(name) {
2909
+ function defaultControllerBrandCheckException$1(name) {
2908
2910
  return new TypeError(`ReadableStreamDefaultController.prototype.${name} can only be used on a ReadableStreamDefaultController`);
2909
2911
  }
2910
2912
 
@@ -2946,7 +2948,6 @@
2946
2948
  if (!canceled2) {
2947
2949
  ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, value2);
2948
2950
  }
2949
- resolveCancelPromise(undefined);
2950
2951
  });
2951
2952
  },
2952
2953
  _closeSteps: () => {
@@ -2957,6 +2958,9 @@
2957
2958
  if (!canceled2) {
2958
2959
  ReadableStreamDefaultControllerClose(branch2._readableStreamController);
2959
2960
  }
2961
+ if (!canceled1 || !canceled2) {
2962
+ resolveCancelPromise(undefined);
2963
+ }
2960
2964
  },
2961
2965
  _errorSteps: () => {
2962
2966
  reading = false;
@@ -2993,7 +2997,9 @@
2993
2997
  uponRejection(reader._closedPromise, (r) => {
2994
2998
  ReadableStreamDefaultControllerError(branch1._readableStreamController, r);
2995
2999
  ReadableStreamDefaultControllerError(branch2._readableStreamController, r);
2996
- resolveCancelPromise(undefined);
3000
+ if (!canceled1 || !canceled2) {
3001
+ resolveCancelPromise(undefined);
3002
+ }
2997
3003
  });
2998
3004
  return [branch1, branch2];
2999
3005
  }
@@ -3535,7 +3541,7 @@
3535
3541
  */
3536
3542
  get readable() {
3537
3543
  if (!IsTransformStream(this)) {
3538
- throw streamBrandCheckException$2('readable');
3544
+ throw streamBrandCheckException('readable');
3539
3545
  }
3540
3546
  return this._readable;
3541
3547
  }
@@ -3544,7 +3550,7 @@
3544
3550
  */
3545
3551
  get writable() {
3546
3552
  if (!IsTransformStream(this)) {
3547
- throw streamBrandCheckException$2('writable');
3553
+ throw streamBrandCheckException('writable');
3548
3554
  }
3549
3555
  return this._writable;
3550
3556
  }
@@ -3637,14 +3643,14 @@
3637
3643
  */
3638
3644
  get desiredSize() {
3639
3645
  if (!IsTransformStreamDefaultController(this)) {
3640
- throw defaultControllerBrandCheckException$1('desiredSize');
3646
+ throw defaultControllerBrandCheckException('desiredSize');
3641
3647
  }
3642
3648
  const readableController = this._controlledTransformStream._readable._readableStreamController;
3643
3649
  return ReadableStreamDefaultControllerGetDesiredSize(readableController);
3644
3650
  }
3645
3651
  enqueue(chunk = undefined) {
3646
3652
  if (!IsTransformStreamDefaultController(this)) {
3647
- throw defaultControllerBrandCheckException$1('enqueue');
3653
+ throw defaultControllerBrandCheckException('enqueue');
3648
3654
  }
3649
3655
  TransformStreamDefaultControllerEnqueue(this, chunk);
3650
3656
  }
@@ -3654,7 +3660,7 @@
3654
3660
  */
3655
3661
  error(reason = undefined) {
3656
3662
  if (!IsTransformStreamDefaultController(this)) {
3657
- throw defaultControllerBrandCheckException$1('error');
3663
+ throw defaultControllerBrandCheckException('error');
3658
3664
  }
3659
3665
  TransformStreamDefaultControllerError(this, reason);
3660
3666
  }
@@ -3664,7 +3670,7 @@
3664
3670
  */
3665
3671
  terminate() {
3666
3672
  if (!IsTransformStreamDefaultController(this)) {
3667
- throw defaultControllerBrandCheckException$1('terminate');
3673
+ throw defaultControllerBrandCheckException('terminate');
3668
3674
  }
3669
3675
  TransformStreamDefaultControllerTerminate(this);
3670
3676
  }
@@ -3806,11 +3812,11 @@
3806
3812
  return stream._backpressureChangePromise;
3807
3813
  }
3808
3814
  // Helper functions for the TransformStreamDefaultController.
3809
- function defaultControllerBrandCheckException$1(name) {
3815
+ function defaultControllerBrandCheckException(name) {
3810
3816
  return new TypeError(`TransformStreamDefaultController.prototype.${name} can only be used on a TransformStreamDefaultController`);
3811
3817
  }
3812
3818
  // Helper functions for the TransformStream.
3813
- function streamBrandCheckException$2(name) {
3819
+ function streamBrandCheckException(name) {
3814
3820
  return new TypeError(`TransformStream.prototype.${name} can only be used on a TransformStream`);
3815
3821
  }
3816
3822