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,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;
@@ -1593,7 +1593,7 @@
1593
1593
  */
1594
1594
  get locked() {
1595
1595
  if (!IsWritableStream(this)) {
1596
- throw streamBrandCheckException('locked');
1596
+ throw streamBrandCheckException$2('locked');
1597
1597
  }
1598
1598
  return IsWritableStreamLocked(this);
1599
1599
  }
@@ -1608,7 +1608,7 @@
1608
1608
  */
1609
1609
  abort(reason = undefined) {
1610
1610
  if (!IsWritableStream(this)) {
1611
- return promiseRejectedWith(streamBrandCheckException('abort'));
1611
+ return promiseRejectedWith(streamBrandCheckException$2('abort'));
1612
1612
  }
1613
1613
  if (IsWritableStreamLocked(this)) {
1614
1614
  return promiseRejectedWith(new TypeError('Cannot abort a stream that already has a writer'));
@@ -1625,7 +1625,7 @@
1625
1625
  */
1626
1626
  close() {
1627
1627
  if (!IsWritableStream(this)) {
1628
- return promiseRejectedWith(streamBrandCheckException('close'));
1628
+ return promiseRejectedWith(streamBrandCheckException$2('close'));
1629
1629
  }
1630
1630
  if (IsWritableStreamLocked(this)) {
1631
1631
  return promiseRejectedWith(new TypeError('Cannot close a stream that already has a writer'));
@@ -1645,7 +1645,7 @@
1645
1645
  */
1646
1646
  getWriter() {
1647
1647
  if (!IsWritableStream(this)) {
1648
- throw streamBrandCheckException('getWriter');
1648
+ throw streamBrandCheckException$2('getWriter');
1649
1649
  }
1650
1650
  return AcquireWritableStreamDefaultWriter(this);
1651
1651
  }
@@ -2356,7 +2356,7 @@
2356
2356
  WritableStreamStartErroring(stream, error);
2357
2357
  }
2358
2358
  // Helper functions for the WritableStream.
2359
- function streamBrandCheckException(name) {
2359
+ function streamBrandCheckException$2(name) {
2360
2360
  return new TypeError(`WritableStream.prototype.${name} can only be used on a WritableStream`);
2361
2361
  }
2362
2362
  // Helper functions for the WritableStreamDefaultWriter.
@@ -2474,6 +2474,7 @@
2474
2474
  }
2475
2475
  }
2476
2476
  function createDOMExceptionPolyfill() {
2477
+ // eslint-disable-next-line no-shadow
2477
2478
  const ctor = function DOMException(message, name) {
2478
2479
  this.message = message || '';
2479
2480
  this.name = name || 'Error';
@@ -2485,6 +2486,7 @@
2485
2486
  Object.defineProperty(ctor.prototype, 'constructor', { value: ctor, writable: true, configurable: true });
2486
2487
  return ctor;
2487
2488
  }
2489
+ // eslint-disable-next-line no-redeclare
2488
2490
  const DOMException$1 = isDOMExceptionConstructor(NativeDOMException) ? NativeDOMException : createDOMExceptionPolyfill();
2489
2491
 
2490
2492
  function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
@@ -2677,7 +2679,7 @@
2677
2679
  */
2678
2680
  get desiredSize() {
2679
2681
  if (!IsReadableStreamDefaultController(this)) {
2680
- throw defaultControllerBrandCheckException('desiredSize');
2682
+ throw defaultControllerBrandCheckException$1('desiredSize');
2681
2683
  }
2682
2684
  return ReadableStreamDefaultControllerGetDesiredSize(this);
2683
2685
  }
@@ -2687,7 +2689,7 @@
2687
2689
  */
2688
2690
  close() {
2689
2691
  if (!IsReadableStreamDefaultController(this)) {
2690
- throw defaultControllerBrandCheckException('close');
2692
+ throw defaultControllerBrandCheckException$1('close');
2691
2693
  }
2692
2694
  if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
2693
2695
  throw new TypeError('The stream is not in a state that permits close');
@@ -2696,7 +2698,7 @@
2696
2698
  }
2697
2699
  enqueue(chunk = undefined) {
2698
2700
  if (!IsReadableStreamDefaultController(this)) {
2699
- throw defaultControllerBrandCheckException('enqueue');
2701
+ throw defaultControllerBrandCheckException$1('enqueue');
2700
2702
  }
2701
2703
  if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
2702
2704
  throw new TypeError('The stream is not in a state that permits enqueue');
@@ -2708,7 +2710,7 @@
2708
2710
  */
2709
2711
  error(e = undefined) {
2710
2712
  if (!IsReadableStreamDefaultController(this)) {
2711
- throw defaultControllerBrandCheckException('error');
2713
+ throw defaultControllerBrandCheckException$1('error');
2712
2714
  }
2713
2715
  ReadableStreamDefaultControllerError(this, e);
2714
2716
  }
@@ -2915,7 +2917,7 @@
2915
2917
  SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
2916
2918
  }
2917
2919
  // Helper functions for the ReadableStreamDefaultController.
2918
- function defaultControllerBrandCheckException(name) {
2920
+ function defaultControllerBrandCheckException$1(name) {
2919
2921
  return new TypeError(`ReadableStreamDefaultController.prototype.${name} can only be used on a ReadableStreamDefaultController`);
2920
2922
  }
2921
2923
 
@@ -2957,7 +2959,6 @@
2957
2959
  if (!canceled2) {
2958
2960
  ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, value2);
2959
2961
  }
2960
- resolveCancelPromise(undefined);
2961
2962
  });
2962
2963
  },
2963
2964
  _closeSteps: () => {
@@ -2968,6 +2969,9 @@
2968
2969
  if (!canceled2) {
2969
2970
  ReadableStreamDefaultControllerClose(branch2._readableStreamController);
2970
2971
  }
2972
+ if (!canceled1 || !canceled2) {
2973
+ resolveCancelPromise(undefined);
2974
+ }
2971
2975
  },
2972
2976
  _errorSteps: () => {
2973
2977
  reading = false;
@@ -3004,7 +3008,9 @@
3004
3008
  uponRejection(reader._closedPromise, (r) => {
3005
3009
  ReadableStreamDefaultControllerError(branch1._readableStreamController, r);
3006
3010
  ReadableStreamDefaultControllerError(branch2._readableStreamController, r);
3007
- resolveCancelPromise(undefined);
3011
+ if (!canceled1 || !canceled2) {
3012
+ resolveCancelPromise(undefined);
3013
+ }
3008
3014
  });
3009
3015
  return [branch1, branch2];
3010
3016
  }
@@ -3546,7 +3552,7 @@
3546
3552
  */
3547
3553
  get readable() {
3548
3554
  if (!IsTransformStream(this)) {
3549
- throw streamBrandCheckException$2('readable');
3555
+ throw streamBrandCheckException('readable');
3550
3556
  }
3551
3557
  return this._readable;
3552
3558
  }
@@ -3555,7 +3561,7 @@
3555
3561
  */
3556
3562
  get writable() {
3557
3563
  if (!IsTransformStream(this)) {
3558
- throw streamBrandCheckException$2('writable');
3564
+ throw streamBrandCheckException('writable');
3559
3565
  }
3560
3566
  return this._writable;
3561
3567
  }
@@ -3648,14 +3654,14 @@
3648
3654
  */
3649
3655
  get desiredSize() {
3650
3656
  if (!IsTransformStreamDefaultController(this)) {
3651
- throw defaultControllerBrandCheckException$1('desiredSize');
3657
+ throw defaultControllerBrandCheckException('desiredSize');
3652
3658
  }
3653
3659
  const readableController = this._controlledTransformStream._readable._readableStreamController;
3654
3660
  return ReadableStreamDefaultControllerGetDesiredSize(readableController);
3655
3661
  }
3656
3662
  enqueue(chunk = undefined) {
3657
3663
  if (!IsTransformStreamDefaultController(this)) {
3658
- throw defaultControllerBrandCheckException$1('enqueue');
3664
+ throw defaultControllerBrandCheckException('enqueue');
3659
3665
  }
3660
3666
  TransformStreamDefaultControllerEnqueue(this, chunk);
3661
3667
  }
@@ -3665,7 +3671,7 @@
3665
3671
  */
3666
3672
  error(reason = undefined) {
3667
3673
  if (!IsTransformStreamDefaultController(this)) {
3668
- throw defaultControllerBrandCheckException$1('error');
3674
+ throw defaultControllerBrandCheckException('error');
3669
3675
  }
3670
3676
  TransformStreamDefaultControllerError(this, reason);
3671
3677
  }
@@ -3675,7 +3681,7 @@
3675
3681
  */
3676
3682
  terminate() {
3677
3683
  if (!IsTransformStreamDefaultController(this)) {
3678
- throw defaultControllerBrandCheckException$1('terminate');
3684
+ throw defaultControllerBrandCheckException('terminate');
3679
3685
  }
3680
3686
  TransformStreamDefaultControllerTerminate(this);
3681
3687
  }
@@ -3817,11 +3823,11 @@
3817
3823
  return stream._backpressureChangePromise;
3818
3824
  }
3819
3825
  // Helper functions for the TransformStreamDefaultController.
3820
- function defaultControllerBrandCheckException$1(name) {
3826
+ function defaultControllerBrandCheckException(name) {
3821
3827
  return new TypeError(`TransformStreamDefaultController.prototype.${name} can only be used on a TransformStreamDefaultController`);
3822
3828
  }
3823
3829
  // Helper functions for the TransformStream.
3824
- function streamBrandCheckException$2(name) {
3830
+ function streamBrandCheckException(name) {
3825
3831
  return new TypeError(`TransformStream.prototype.${name} can only be used on a TransformStream`);
3826
3832
  }
3827
3833