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/dist/polyfill.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * web-streams-polyfill v3.0.2
2
+ * web-streams-polyfill v3.0.3
3
3
  */
4
4
  /// <reference lib="es2015.symbol" />
5
5
  var SymbolPolyfill = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ?
@@ -8,7 +8,7 @@ var SymbolPolyfill = typeof Symbol === 'function' && typeof Symbol.iterator ===
8
8
 
9
9
  /// <reference lib="dom" />
10
10
  function noop() {
11
- // do nothing
11
+ return undefined;
12
12
  }
13
13
  function getGlobals() {
14
14
  if (typeof self !== 'undefined') {
@@ -27,7 +27,7 @@ var globals = getGlobals();
27
27
  function typeIsObject(x) {
28
28
  return (typeof x === 'object' && x !== null) || typeof x === 'function';
29
29
  }
30
- var rethrowAssertionErrorRejection = noop;
30
+ var rethrowAssertionErrorRejection = noop;
31
31
 
32
32
  var originalPromise = Promise;
33
33
  var originalPromiseThen = Promise.prototype.then;
@@ -1627,7 +1627,7 @@ var WritableStream = /** @class */ (function () {
1627
1627
  */
1628
1628
  get: function () {
1629
1629
  if (!IsWritableStream(this)) {
1630
- throw streamBrandCheckException('locked');
1630
+ throw streamBrandCheckException$2('locked');
1631
1631
  }
1632
1632
  return IsWritableStreamLocked(this);
1633
1633
  },
@@ -1646,7 +1646,7 @@ var WritableStream = /** @class */ (function () {
1646
1646
  WritableStream.prototype.abort = function (reason) {
1647
1647
  if (reason === void 0) { reason = undefined; }
1648
1648
  if (!IsWritableStream(this)) {
1649
- return promiseRejectedWith(streamBrandCheckException('abort'));
1649
+ return promiseRejectedWith(streamBrandCheckException$2('abort'));
1650
1650
  }
1651
1651
  if (IsWritableStreamLocked(this)) {
1652
1652
  return promiseRejectedWith(new TypeError('Cannot abort a stream that already has a writer'));
@@ -1663,7 +1663,7 @@ var WritableStream = /** @class */ (function () {
1663
1663
  */
1664
1664
  WritableStream.prototype.close = function () {
1665
1665
  if (!IsWritableStream(this)) {
1666
- return promiseRejectedWith(streamBrandCheckException('close'));
1666
+ return promiseRejectedWith(streamBrandCheckException$2('close'));
1667
1667
  }
1668
1668
  if (IsWritableStreamLocked(this)) {
1669
1669
  return promiseRejectedWith(new TypeError('Cannot close a stream that already has a writer'));
@@ -1683,7 +1683,7 @@ var WritableStream = /** @class */ (function () {
1683
1683
  */
1684
1684
  WritableStream.prototype.getWriter = function () {
1685
1685
  if (!IsWritableStream(this)) {
1686
- throw streamBrandCheckException('getWriter');
1686
+ throw streamBrandCheckException$2('getWriter');
1687
1687
  }
1688
1688
  return AcquireWritableStreamDefaultWriter(this);
1689
1689
  };
@@ -2414,7 +2414,7 @@ function WritableStreamDefaultControllerError(controller, error) {
2414
2414
  WritableStreamStartErroring(stream, error);
2415
2415
  }
2416
2416
  // Helper functions for the WritableStream.
2417
- function streamBrandCheckException(name) {
2417
+ function streamBrandCheckException$2(name) {
2418
2418
  return new TypeError("WritableStream.prototype." + name + " can only be used on a WritableStream");
2419
2419
  }
2420
2420
  // Helper functions for the WritableStreamDefaultWriter.
@@ -2532,6 +2532,7 @@ function isDOMExceptionConstructor(ctor) {
2532
2532
  }
2533
2533
  }
2534
2534
  function createDOMExceptionPolyfill() {
2535
+ // eslint-disable-next-line no-shadow
2535
2536
  var ctor = function DOMException(message, name) {
2536
2537
  this.message = message || '';
2537
2538
  this.name = name || 'Error';
@@ -2543,6 +2544,7 @@ function createDOMExceptionPolyfill() {
2543
2544
  Object.defineProperty(ctor.prototype, 'constructor', { value: ctor, writable: true, configurable: true });
2544
2545
  return ctor;
2545
2546
  }
2547
+ // eslint-disable-next-line no-redeclare
2546
2548
  var DOMException$1 = isDOMExceptionConstructor(NativeDOMException) ? NativeDOMException : createDOMExceptionPolyfill();
2547
2549
 
2548
2550
  function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
@@ -2736,7 +2738,7 @@ var ReadableStreamDefaultController = /** @class */ (function () {
2736
2738
  */
2737
2739
  get: function () {
2738
2740
  if (!IsReadableStreamDefaultController(this)) {
2739
- throw defaultControllerBrandCheckException('desiredSize');
2741
+ throw defaultControllerBrandCheckException$1('desiredSize');
2740
2742
  }
2741
2743
  return ReadableStreamDefaultControllerGetDesiredSize(this);
2742
2744
  },
@@ -2749,7 +2751,7 @@ var ReadableStreamDefaultController = /** @class */ (function () {
2749
2751
  */
2750
2752
  ReadableStreamDefaultController.prototype.close = function () {
2751
2753
  if (!IsReadableStreamDefaultController(this)) {
2752
- throw defaultControllerBrandCheckException('close');
2754
+ throw defaultControllerBrandCheckException$1('close');
2753
2755
  }
2754
2756
  if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
2755
2757
  throw new TypeError('The stream is not in a state that permits close');
@@ -2759,7 +2761,7 @@ var ReadableStreamDefaultController = /** @class */ (function () {
2759
2761
  ReadableStreamDefaultController.prototype.enqueue = function (chunk) {
2760
2762
  if (chunk === void 0) { chunk = undefined; }
2761
2763
  if (!IsReadableStreamDefaultController(this)) {
2762
- throw defaultControllerBrandCheckException('enqueue');
2764
+ throw defaultControllerBrandCheckException$1('enqueue');
2763
2765
  }
2764
2766
  if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
2765
2767
  throw new TypeError('The stream is not in a state that permits enqueue');
@@ -2772,7 +2774,7 @@ var ReadableStreamDefaultController = /** @class */ (function () {
2772
2774
  ReadableStreamDefaultController.prototype.error = function (e) {
2773
2775
  if (e === void 0) { e = undefined; }
2774
2776
  if (!IsReadableStreamDefaultController(this)) {
2775
- throw defaultControllerBrandCheckException('error');
2777
+ throw defaultControllerBrandCheckException$1('error');
2776
2778
  }
2777
2779
  ReadableStreamDefaultControllerError(this, e);
2778
2780
  };
@@ -2980,7 +2982,7 @@ function SetUpReadableStreamDefaultControllerFromUnderlyingSource(stream, underl
2980
2982
  SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
2981
2983
  }
2982
2984
  // Helper functions for the ReadableStreamDefaultController.
2983
- function defaultControllerBrandCheckException(name) {
2985
+ function defaultControllerBrandCheckException$1(name) {
2984
2986
  return new TypeError("ReadableStreamDefaultController.prototype." + name + " can only be used on a ReadableStreamDefaultController");
2985
2987
  }
2986
2988
 
@@ -3022,7 +3024,6 @@ function ReadableStreamTee(stream, cloneForBranch2) {
3022
3024
  if (!canceled2) {
3023
3025
  ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, value2);
3024
3026
  }
3025
- resolveCancelPromise(undefined);
3026
3027
  });
3027
3028
  },
3028
3029
  _closeSteps: function () {
@@ -3033,6 +3034,9 @@ function ReadableStreamTee(stream, cloneForBranch2) {
3033
3034
  if (!canceled2) {
3034
3035
  ReadableStreamDefaultControllerClose(branch2._readableStreamController);
3035
3036
  }
3037
+ if (!canceled1 || !canceled2) {
3038
+ resolveCancelPromise(undefined);
3039
+ }
3036
3040
  },
3037
3041
  _errorSteps: function () {
3038
3042
  reading = false;
@@ -3069,7 +3073,9 @@ function ReadableStreamTee(stream, cloneForBranch2) {
3069
3073
  uponRejection(reader._closedPromise, function (r) {
3070
3074
  ReadableStreamDefaultControllerError(branch1._readableStreamController, r);
3071
3075
  ReadableStreamDefaultControllerError(branch2._readableStreamController, r);
3072
- resolveCancelPromise(undefined);
3076
+ if (!canceled1 || !canceled2) {
3077
+ resolveCancelPromise(undefined);
3078
+ }
3073
3079
  });
3074
3080
  return [branch1, branch2];
3075
3081
  }
@@ -3647,7 +3653,7 @@ var TransformStream = /** @class */ (function () {
3647
3653
  */
3648
3654
  get: function () {
3649
3655
  if (!IsTransformStream(this)) {
3650
- throw streamBrandCheckException$2('readable');
3656
+ throw streamBrandCheckException('readable');
3651
3657
  }
3652
3658
  return this._readable;
3653
3659
  },
@@ -3660,7 +3666,7 @@ var TransformStream = /** @class */ (function () {
3660
3666
  */
3661
3667
  get: function () {
3662
3668
  if (!IsTransformStream(this)) {
3663
- throw streamBrandCheckException$2('writable');
3669
+ throw streamBrandCheckException('writable');
3664
3670
  }
3665
3671
  return this._writable;
3666
3672
  },
@@ -3758,7 +3764,7 @@ var TransformStreamDefaultController = /** @class */ (function () {
3758
3764
  */
3759
3765
  get: function () {
3760
3766
  if (!IsTransformStreamDefaultController(this)) {
3761
- throw defaultControllerBrandCheckException$1('desiredSize');
3767
+ throw defaultControllerBrandCheckException('desiredSize');
3762
3768
  }
3763
3769
  var readableController = this._controlledTransformStream._readable._readableStreamController;
3764
3770
  return ReadableStreamDefaultControllerGetDesiredSize(readableController);
@@ -3769,7 +3775,7 @@ var TransformStreamDefaultController = /** @class */ (function () {
3769
3775
  TransformStreamDefaultController.prototype.enqueue = function (chunk) {
3770
3776
  if (chunk === void 0) { chunk = undefined; }
3771
3777
  if (!IsTransformStreamDefaultController(this)) {
3772
- throw defaultControllerBrandCheckException$1('enqueue');
3778
+ throw defaultControllerBrandCheckException('enqueue');
3773
3779
  }
3774
3780
  TransformStreamDefaultControllerEnqueue(this, chunk);
3775
3781
  };
@@ -3780,7 +3786,7 @@ var TransformStreamDefaultController = /** @class */ (function () {
3780
3786
  TransformStreamDefaultController.prototype.error = function (reason) {
3781
3787
  if (reason === void 0) { reason = undefined; }
3782
3788
  if (!IsTransformStreamDefaultController(this)) {
3783
- throw defaultControllerBrandCheckException$1('error');
3789
+ throw defaultControllerBrandCheckException('error');
3784
3790
  }
3785
3791
  TransformStreamDefaultControllerError(this, reason);
3786
3792
  };
@@ -3790,7 +3796,7 @@ var TransformStreamDefaultController = /** @class */ (function () {
3790
3796
  */
3791
3797
  TransformStreamDefaultController.prototype.terminate = function () {
3792
3798
  if (!IsTransformStreamDefaultController(this)) {
3793
- throw defaultControllerBrandCheckException$1('terminate');
3799
+ throw defaultControllerBrandCheckException('terminate');
3794
3800
  }
3795
3801
  TransformStreamDefaultControllerTerminate(this);
3796
3802
  };
@@ -3933,11 +3939,11 @@ function TransformStreamDefaultSourcePullAlgorithm(stream) {
3933
3939
  return stream._backpressureChangePromise;
3934
3940
  }
3935
3941
  // Helper functions for the TransformStreamDefaultController.
3936
- function defaultControllerBrandCheckException$1(name) {
3942
+ function defaultControllerBrandCheckException(name) {
3937
3943
  return new TypeError("TransformStreamDefaultController.prototype." + name + " can only be used on a TransformStreamDefaultController");
3938
3944
  }
3939
3945
  // Helper functions for the TransformStream.
3940
- function streamBrandCheckException$2(name) {
3946
+ function streamBrandCheckException(name) {
3941
3947
  return new TypeError("TransformStream.prototype." + name + " can only be used on a TransformStream");
3942
3948
  }
3943
3949