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.
@@ -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
  const SymbolPolyfill = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ?
@@ -8,7 +8,7 @@ const 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 @@ const globals = getGlobals();
27
27
  function typeIsObject(x) {
28
28
  return (typeof x === 'object' && x !== null) || typeof x === 'function';
29
29
  }
30
- const rethrowAssertionErrorRejection = noop;
30
+ const rethrowAssertionErrorRejection = noop;
31
31
 
32
32
  const originalPromise = Promise;
33
33
  const originalPromiseThen = Promise.prototype.then;
@@ -1587,7 +1587,7 @@ class WritableStream {
1587
1587
  */
1588
1588
  get locked() {
1589
1589
  if (!IsWritableStream(this)) {
1590
- throw streamBrandCheckException('locked');
1590
+ throw streamBrandCheckException$2('locked');
1591
1591
  }
1592
1592
  return IsWritableStreamLocked(this);
1593
1593
  }
@@ -1602,7 +1602,7 @@ class WritableStream {
1602
1602
  */
1603
1603
  abort(reason = undefined) {
1604
1604
  if (!IsWritableStream(this)) {
1605
- return promiseRejectedWith(streamBrandCheckException('abort'));
1605
+ return promiseRejectedWith(streamBrandCheckException$2('abort'));
1606
1606
  }
1607
1607
  if (IsWritableStreamLocked(this)) {
1608
1608
  return promiseRejectedWith(new TypeError('Cannot abort a stream that already has a writer'));
@@ -1619,7 +1619,7 @@ class WritableStream {
1619
1619
  */
1620
1620
  close() {
1621
1621
  if (!IsWritableStream(this)) {
1622
- return promiseRejectedWith(streamBrandCheckException('close'));
1622
+ return promiseRejectedWith(streamBrandCheckException$2('close'));
1623
1623
  }
1624
1624
  if (IsWritableStreamLocked(this)) {
1625
1625
  return promiseRejectedWith(new TypeError('Cannot close a stream that already has a writer'));
@@ -1639,7 +1639,7 @@ class WritableStream {
1639
1639
  */
1640
1640
  getWriter() {
1641
1641
  if (!IsWritableStream(this)) {
1642
- throw streamBrandCheckException('getWriter');
1642
+ throw streamBrandCheckException$2('getWriter');
1643
1643
  }
1644
1644
  return AcquireWritableStreamDefaultWriter(this);
1645
1645
  }
@@ -2350,7 +2350,7 @@ function WritableStreamDefaultControllerError(controller, error) {
2350
2350
  WritableStreamStartErroring(stream, error);
2351
2351
  }
2352
2352
  // Helper functions for the WritableStream.
2353
- function streamBrandCheckException(name) {
2353
+ function streamBrandCheckException$2(name) {
2354
2354
  return new TypeError(`WritableStream.prototype.${name} can only be used on a WritableStream`);
2355
2355
  }
2356
2356
  // Helper functions for the WritableStreamDefaultWriter.
@@ -2468,6 +2468,7 @@ function isDOMExceptionConstructor(ctor) {
2468
2468
  }
2469
2469
  }
2470
2470
  function createDOMExceptionPolyfill() {
2471
+ // eslint-disable-next-line no-shadow
2471
2472
  const ctor = function DOMException(message, name) {
2472
2473
  this.message = message || '';
2473
2474
  this.name = name || 'Error';
@@ -2479,6 +2480,7 @@ function createDOMExceptionPolyfill() {
2479
2480
  Object.defineProperty(ctor.prototype, 'constructor', { value: ctor, writable: true, configurable: true });
2480
2481
  return ctor;
2481
2482
  }
2483
+ // eslint-disable-next-line no-redeclare
2482
2484
  const DOMException$1 = isDOMExceptionConstructor(NativeDOMException) ? NativeDOMException : createDOMExceptionPolyfill();
2483
2485
 
2484
2486
  function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
@@ -2671,7 +2673,7 @@ class ReadableStreamDefaultController {
2671
2673
  */
2672
2674
  get desiredSize() {
2673
2675
  if (!IsReadableStreamDefaultController(this)) {
2674
- throw defaultControllerBrandCheckException('desiredSize');
2676
+ throw defaultControllerBrandCheckException$1('desiredSize');
2675
2677
  }
2676
2678
  return ReadableStreamDefaultControllerGetDesiredSize(this);
2677
2679
  }
@@ -2681,7 +2683,7 @@ class ReadableStreamDefaultController {
2681
2683
  */
2682
2684
  close() {
2683
2685
  if (!IsReadableStreamDefaultController(this)) {
2684
- throw defaultControllerBrandCheckException('close');
2686
+ throw defaultControllerBrandCheckException$1('close');
2685
2687
  }
2686
2688
  if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
2687
2689
  throw new TypeError('The stream is not in a state that permits close');
@@ -2690,7 +2692,7 @@ class ReadableStreamDefaultController {
2690
2692
  }
2691
2693
  enqueue(chunk = undefined) {
2692
2694
  if (!IsReadableStreamDefaultController(this)) {
2693
- throw defaultControllerBrandCheckException('enqueue');
2695
+ throw defaultControllerBrandCheckException$1('enqueue');
2694
2696
  }
2695
2697
  if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
2696
2698
  throw new TypeError('The stream is not in a state that permits enqueue');
@@ -2702,7 +2704,7 @@ class ReadableStreamDefaultController {
2702
2704
  */
2703
2705
  error(e = undefined) {
2704
2706
  if (!IsReadableStreamDefaultController(this)) {
2705
- throw defaultControllerBrandCheckException('error');
2707
+ throw defaultControllerBrandCheckException$1('error');
2706
2708
  }
2707
2709
  ReadableStreamDefaultControllerError(this, e);
2708
2710
  }
@@ -2909,7 +2911,7 @@ function SetUpReadableStreamDefaultControllerFromUnderlyingSource(stream, underl
2909
2911
  SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
2910
2912
  }
2911
2913
  // Helper functions for the ReadableStreamDefaultController.
2912
- function defaultControllerBrandCheckException(name) {
2914
+ function defaultControllerBrandCheckException$1(name) {
2913
2915
  return new TypeError(`ReadableStreamDefaultController.prototype.${name} can only be used on a ReadableStreamDefaultController`);
2914
2916
  }
2915
2917
 
@@ -2951,7 +2953,6 @@ function ReadableStreamTee(stream, cloneForBranch2) {
2951
2953
  if (!canceled2) {
2952
2954
  ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, value2);
2953
2955
  }
2954
- resolveCancelPromise(undefined);
2955
2956
  });
2956
2957
  },
2957
2958
  _closeSteps: () => {
@@ -2962,6 +2963,9 @@ function ReadableStreamTee(stream, cloneForBranch2) {
2962
2963
  if (!canceled2) {
2963
2964
  ReadableStreamDefaultControllerClose(branch2._readableStreamController);
2964
2965
  }
2966
+ if (!canceled1 || !canceled2) {
2967
+ resolveCancelPromise(undefined);
2968
+ }
2965
2969
  },
2966
2970
  _errorSteps: () => {
2967
2971
  reading = false;
@@ -2998,7 +3002,9 @@ function ReadableStreamTee(stream, cloneForBranch2) {
2998
3002
  uponRejection(reader._closedPromise, (r) => {
2999
3003
  ReadableStreamDefaultControllerError(branch1._readableStreamController, r);
3000
3004
  ReadableStreamDefaultControllerError(branch2._readableStreamController, r);
3001
- resolveCancelPromise(undefined);
3005
+ if (!canceled1 || !canceled2) {
3006
+ resolveCancelPromise(undefined);
3007
+ }
3002
3008
  });
3003
3009
  return [branch1, branch2];
3004
3010
  }
@@ -3540,7 +3546,7 @@ class TransformStream {
3540
3546
  */
3541
3547
  get readable() {
3542
3548
  if (!IsTransformStream(this)) {
3543
- throw streamBrandCheckException$2('readable');
3549
+ throw streamBrandCheckException('readable');
3544
3550
  }
3545
3551
  return this._readable;
3546
3552
  }
@@ -3549,7 +3555,7 @@ class TransformStream {
3549
3555
  */
3550
3556
  get writable() {
3551
3557
  if (!IsTransformStream(this)) {
3552
- throw streamBrandCheckException$2('writable');
3558
+ throw streamBrandCheckException('writable');
3553
3559
  }
3554
3560
  return this._writable;
3555
3561
  }
@@ -3642,14 +3648,14 @@ class TransformStreamDefaultController {
3642
3648
  */
3643
3649
  get desiredSize() {
3644
3650
  if (!IsTransformStreamDefaultController(this)) {
3645
- throw defaultControllerBrandCheckException$1('desiredSize');
3651
+ throw defaultControllerBrandCheckException('desiredSize');
3646
3652
  }
3647
3653
  const readableController = this._controlledTransformStream._readable._readableStreamController;
3648
3654
  return ReadableStreamDefaultControllerGetDesiredSize(readableController);
3649
3655
  }
3650
3656
  enqueue(chunk = undefined) {
3651
3657
  if (!IsTransformStreamDefaultController(this)) {
3652
- throw defaultControllerBrandCheckException$1('enqueue');
3658
+ throw defaultControllerBrandCheckException('enqueue');
3653
3659
  }
3654
3660
  TransformStreamDefaultControllerEnqueue(this, chunk);
3655
3661
  }
@@ -3659,7 +3665,7 @@ class TransformStreamDefaultController {
3659
3665
  */
3660
3666
  error(reason = undefined) {
3661
3667
  if (!IsTransformStreamDefaultController(this)) {
3662
- throw defaultControllerBrandCheckException$1('error');
3668
+ throw defaultControllerBrandCheckException('error');
3663
3669
  }
3664
3670
  TransformStreamDefaultControllerError(this, reason);
3665
3671
  }
@@ -3669,7 +3675,7 @@ class TransformStreamDefaultController {
3669
3675
  */
3670
3676
  terminate() {
3671
3677
  if (!IsTransformStreamDefaultController(this)) {
3672
- throw defaultControllerBrandCheckException$1('terminate');
3678
+ throw defaultControllerBrandCheckException('terminate');
3673
3679
  }
3674
3680
  TransformStreamDefaultControllerTerminate(this);
3675
3681
  }
@@ -3811,11 +3817,11 @@ function TransformStreamDefaultSourcePullAlgorithm(stream) {
3811
3817
  return stream._backpressureChangePromise;
3812
3818
  }
3813
3819
  // Helper functions for the TransformStreamDefaultController.
3814
- function defaultControllerBrandCheckException$1(name) {
3820
+ function defaultControllerBrandCheckException(name) {
3815
3821
  return new TypeError(`TransformStreamDefaultController.prototype.${name} can only be used on a TransformStreamDefaultController`);
3816
3822
  }
3817
3823
  // Helper functions for the TransformStream.
3818
- function streamBrandCheckException$2(name) {
3824
+ function streamBrandCheckException(name) {
3819
3825
  return new TypeError(`TransformStream.prototype.${name} can only be used on a TransformStream`);
3820
3826
  }
3821
3827