web-streams-polyfill 3.3.1 → 3.3.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/README.md CHANGED
@@ -5,7 +5,6 @@ Web Streams, based on the WHATWG spec reference implementation.
5
5
  [![build status](https://api.travis-ci.com/MattiasBuelens/web-streams-polyfill.svg?branch=master)](https://travis-ci.com/MattiasBuelens/web-streams-polyfill)
6
6
  [![npm version](https://img.shields.io/npm/v/web-streams-polyfill.svg)](https://www.npmjs.com/package/web-streams-polyfill)
7
7
  [![license](https://img.shields.io/npm/l/web-streams-polyfill.svg)](https://github.com/MattiasBuelens/web-streams-polyfill/blob/master/LICENSE)
8
- [![Join the chat at https://gitter.im/web-streams-polyfill/Lobby](https://badges.gitter.im/web-streams-polyfill/Lobby.svg)](https://gitter.im/web-streams-polyfill/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
9
8
 
10
9
  ## Links
11
10
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * web-streams-polyfill v3.3.1
3
+ * web-streams-polyfill v3.3.3
4
4
  * Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
5
5
  * This code is released under the MIT license.
6
6
  * SPDX-License-Identifier: MIT
@@ -11,11 +11,6 @@
11
11
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.WebStreamsPolyfill = {}));
12
12
  })(this, (function (exports) { 'use strict';
13
13
 
14
- /// <reference lib="es2015.symbol" />
15
- const SymbolPolyfill = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ?
16
- Symbol :
17
- description => `Symbol(${description})`;
18
-
19
14
  function noop() {
20
15
  return undefined;
21
16
  }
@@ -208,11 +203,11 @@
208
203
  }
209
204
  }
210
205
 
211
- const AbortSteps = SymbolPolyfill('[[AbortSteps]]');
212
- const ErrorSteps = SymbolPolyfill('[[ErrorSteps]]');
213
- const CancelSteps = SymbolPolyfill('[[CancelSteps]]');
214
- const PullSteps = SymbolPolyfill('[[PullSteps]]');
215
- const ReleaseSteps = SymbolPolyfill('[[ReleaseSteps]]');
206
+ const AbortSteps = Symbol('[[AbortSteps]]');
207
+ const ErrorSteps = Symbol('[[ErrorSteps]]');
208
+ const CancelSteps = Symbol('[[CancelSteps]]');
209
+ const PullSteps = Symbol('[[PullSteps]]');
210
+ const ReleaseSteps = Symbol('[[ReleaseSteps]]');
216
211
 
217
212
  function ReadableStreamReaderGenericInitialize(reader, stream) {
218
213
  reader._ownerReadableStream = stream;
@@ -492,8 +487,8 @@
492
487
  setFunctionName(ReadableStreamDefaultReader.prototype.cancel, 'cancel');
493
488
  setFunctionName(ReadableStreamDefaultReader.prototype.read, 'read');
494
489
  setFunctionName(ReadableStreamDefaultReader.prototype.releaseLock, 'releaseLock');
495
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
496
- Object.defineProperty(ReadableStreamDefaultReader.prototype, SymbolPolyfill.toStringTag, {
490
+ if (typeof Symbol.toStringTag === 'symbol') {
491
+ Object.defineProperty(ReadableStreamDefaultReader.prototype, Symbol.toStringTag, {
497
492
  value: 'ReadableStreamDefaultReader',
498
493
  configurable: true
499
494
  });
@@ -626,9 +621,7 @@
626
621
  return this._asyncIteratorImpl.return(value);
627
622
  }
628
623
  };
629
- if (AsyncIteratorPrototype !== undefined) {
630
- Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype);
631
- }
624
+ Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype);
632
625
  // Abstract operations for the ReadableStream.
633
626
  function AcquireReadableStreamAsyncIterator(stream, preventCancel) {
634
627
  const reader = AcquireReadableStreamDefaultReader(stream);
@@ -665,6 +658,7 @@
665
658
  return x !== x;
666
659
  };
667
660
 
661
+ var _a, _b, _c;
668
662
  function CreateArrayFromList(elements) {
669
663
  // We use arrays to represent lists, so this is basically a no-op.
670
664
  // Do a slice though just in case we happen to depend on the unique-ness.
@@ -722,7 +716,7 @@
722
716
  // we use yield* inside an async generator function to achieve the same result.
723
717
  // Wrap the sync iterator inside a sync iterable, so we can use it with yield*.
724
718
  const syncIterable = {
725
- [SymbolPolyfill.iterator]: () => syncIteratorRecord.iterator
719
+ [Symbol.iterator]: () => syncIteratorRecord.iterator
726
720
  };
727
721
  // Create an async generator function and immediately invoke it.
728
722
  const asyncIterator = (async function* () {
@@ -732,18 +726,20 @@
732
726
  const nextMethod = asyncIterator.next;
733
727
  return { iterator: asyncIterator, nextMethod, done: false };
734
728
  }
729
+ // Aligns with core-js/modules/es.symbol.async-iterator.js
730
+ const SymbolAsyncIterator = (_c = (_a = Symbol.asyncIterator) !== null && _a !== void 0 ? _a : (_b = Symbol.for) === null || _b === void 0 ? void 0 : _b.call(Symbol, 'Symbol.asyncIterator')) !== null && _c !== void 0 ? _c : '@@asyncIterator';
735
731
  function GetIterator(obj, hint = 'sync', method) {
736
732
  if (method === undefined) {
737
733
  if (hint === 'async') {
738
- method = GetMethod(obj, SymbolPolyfill.asyncIterator);
734
+ method = GetMethod(obj, SymbolAsyncIterator);
739
735
  if (method === undefined) {
740
- const syncMethod = GetMethod(obj, SymbolPolyfill.iterator);
736
+ const syncMethod = GetMethod(obj, Symbol.iterator);
741
737
  const syncIteratorRecord = GetIterator(obj, 'sync', syncMethod);
742
738
  return CreateAsyncFromSyncIterator(syncIteratorRecord);
743
739
  }
744
740
  }
745
741
  else {
746
- method = GetMethod(obj, SymbolPolyfill.iterator);
742
+ method = GetMethod(obj, Symbol.iterator);
747
743
  }
748
744
  }
749
745
  if (method === undefined) {
@@ -880,8 +876,8 @@
880
876
  });
881
877
  setFunctionName(ReadableStreamBYOBRequest.prototype.respond, 'respond');
882
878
  setFunctionName(ReadableStreamBYOBRequest.prototype.respondWithNewView, 'respondWithNewView');
883
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
884
- Object.defineProperty(ReadableStreamBYOBRequest.prototype, SymbolPolyfill.toStringTag, {
879
+ if (typeof Symbol.toStringTag === 'symbol') {
880
+ Object.defineProperty(ReadableStreamBYOBRequest.prototype, Symbol.toStringTag, {
885
881
  value: 'ReadableStreamBYOBRequest',
886
882
  configurable: true
887
883
  });
@@ -1024,8 +1020,8 @@
1024
1020
  setFunctionName(ReadableByteStreamController.prototype.close, 'close');
1025
1021
  setFunctionName(ReadableByteStreamController.prototype.enqueue, 'enqueue');
1026
1022
  setFunctionName(ReadableByteStreamController.prototype.error, 'error');
1027
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
1028
- Object.defineProperty(ReadableByteStreamController.prototype, SymbolPolyfill.toStringTag, {
1023
+ if (typeof Symbol.toStringTag === 'symbol') {
1024
+ Object.defineProperty(ReadableByteStreamController.prototype, Symbol.toStringTag, {
1029
1025
  value: 'ReadableByteStreamController',
1030
1026
  configurable: true
1031
1027
  });
@@ -1713,8 +1709,8 @@
1713
1709
  setFunctionName(ReadableStreamBYOBReader.prototype.cancel, 'cancel');
1714
1710
  setFunctionName(ReadableStreamBYOBReader.prototype.read, 'read');
1715
1711
  setFunctionName(ReadableStreamBYOBReader.prototype.releaseLock, 'releaseLock');
1716
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
1717
- Object.defineProperty(ReadableStreamBYOBReader.prototype, SymbolPolyfill.toStringTag, {
1712
+ if (typeof Symbol.toStringTag === 'symbol') {
1713
+ Object.defineProperty(ReadableStreamBYOBReader.prototype, Symbol.toStringTag, {
1718
1714
  value: 'ReadableStreamBYOBReader',
1719
1715
  configurable: true
1720
1716
  });
@@ -1954,8 +1950,8 @@
1954
1950
  setFunctionName(WritableStream.prototype.abort, 'abort');
1955
1951
  setFunctionName(WritableStream.prototype.close, 'close');
1956
1952
  setFunctionName(WritableStream.prototype.getWriter, 'getWriter');
1957
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
1958
- Object.defineProperty(WritableStream.prototype, SymbolPolyfill.toStringTag, {
1953
+ if (typeof Symbol.toStringTag === 'symbol') {
1954
+ Object.defineProperty(WritableStream.prototype, Symbol.toStringTag, {
1959
1955
  value: 'WritableStream',
1960
1956
  configurable: true
1961
1957
  });
@@ -2360,8 +2356,8 @@
2360
2356
  setFunctionName(WritableStreamDefaultWriter.prototype.close, 'close');
2361
2357
  setFunctionName(WritableStreamDefaultWriter.prototype.releaseLock, 'releaseLock');
2362
2358
  setFunctionName(WritableStreamDefaultWriter.prototype.write, 'write');
2363
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
2364
- Object.defineProperty(WritableStreamDefaultWriter.prototype, SymbolPolyfill.toStringTag, {
2359
+ if (typeof Symbol.toStringTag === 'symbol') {
2360
+ Object.defineProperty(WritableStreamDefaultWriter.prototype, Symbol.toStringTag, {
2365
2361
  value: 'WritableStreamDefaultWriter',
2366
2362
  configurable: true
2367
2363
  });
@@ -2527,8 +2523,8 @@
2527
2523
  signal: { enumerable: true },
2528
2524
  error: { enumerable: true }
2529
2525
  });
2530
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
2531
- Object.defineProperty(WritableStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
2526
+ if (typeof Symbol.toStringTag === 'symbol') {
2527
+ Object.defineProperty(WritableStreamDefaultController.prototype, Symbol.toStringTag, {
2532
2528
  value: 'WritableStreamDefaultController',
2533
2529
  configurable: true
2534
2530
  });
@@ -3142,8 +3138,8 @@
3142
3138
  setFunctionName(ReadableStreamDefaultController.prototype.close, 'close');
3143
3139
  setFunctionName(ReadableStreamDefaultController.prototype.enqueue, 'enqueue');
3144
3140
  setFunctionName(ReadableStreamDefaultController.prototype.error, 'error');
3145
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
3146
- Object.defineProperty(ReadableStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
3141
+ if (typeof Symbol.toStringTag === 'symbol') {
3142
+ Object.defineProperty(ReadableStreamDefaultController.prototype, Symbol.toStringTag, {
3147
3143
  value: 'ReadableStreamDefaultController',
3148
3144
  configurable: true
3149
3145
  });
@@ -3978,6 +3974,10 @@
3978
3974
  const options = convertIteratorOptions(rawOptions, 'First parameter');
3979
3975
  return AcquireReadableStreamAsyncIterator(this, options.preventCancel);
3980
3976
  }
3977
+ [SymbolAsyncIterator](options) {
3978
+ // Stub implementation, overridden below
3979
+ return this.values(options);
3980
+ }
3981
3981
  /**
3982
3982
  * Creates a new ReadableStream wrapping the provided iterable or async iterable.
3983
3983
  *
@@ -4007,19 +4007,17 @@
4007
4007
  setFunctionName(ReadableStream.prototype.pipeTo, 'pipeTo');
4008
4008
  setFunctionName(ReadableStream.prototype.tee, 'tee');
4009
4009
  setFunctionName(ReadableStream.prototype.values, 'values');
4010
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
4011
- Object.defineProperty(ReadableStream.prototype, SymbolPolyfill.toStringTag, {
4010
+ if (typeof Symbol.toStringTag === 'symbol') {
4011
+ Object.defineProperty(ReadableStream.prototype, Symbol.toStringTag, {
4012
4012
  value: 'ReadableStream',
4013
4013
  configurable: true
4014
4014
  });
4015
4015
  }
4016
- if (typeof SymbolPolyfill.asyncIterator === 'symbol') {
4017
- Object.defineProperty(ReadableStream.prototype, SymbolPolyfill.asyncIterator, {
4018
- value: ReadableStream.prototype.values,
4019
- writable: true,
4020
- configurable: true
4021
- });
4022
- }
4016
+ Object.defineProperty(ReadableStream.prototype, SymbolAsyncIterator, {
4017
+ value: ReadableStream.prototype.values,
4018
+ writable: true,
4019
+ configurable: true
4020
+ });
4023
4021
  // Abstract operations for the ReadableStream.
4024
4022
  // Throws if and only if startAlgorithm throws.
4025
4023
  function CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark = 1, sizeAlgorithm = () => 1) {
@@ -4162,8 +4160,8 @@
4162
4160
  highWaterMark: { enumerable: true },
4163
4161
  size: { enumerable: true }
4164
4162
  });
4165
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
4166
- Object.defineProperty(ByteLengthQueuingStrategy.prototype, SymbolPolyfill.toStringTag, {
4163
+ if (typeof Symbol.toStringTag === 'symbol') {
4164
+ Object.defineProperty(ByteLengthQueuingStrategy.prototype, Symbol.toStringTag, {
4167
4165
  value: 'ByteLengthQueuingStrategy',
4168
4166
  configurable: true
4169
4167
  });
@@ -4222,8 +4220,8 @@
4222
4220
  highWaterMark: { enumerable: true },
4223
4221
  size: { enumerable: true }
4224
4222
  });
4225
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
4226
- Object.defineProperty(CountQueuingStrategy.prototype, SymbolPolyfill.toStringTag, {
4223
+ if (typeof Symbol.toStringTag === 'symbol') {
4224
+ Object.defineProperty(CountQueuingStrategy.prototype, Symbol.toStringTag, {
4227
4225
  value: 'CountQueuingStrategy',
4228
4226
  configurable: true
4229
4227
  });
@@ -4347,8 +4345,8 @@
4347
4345
  readable: { enumerable: true },
4348
4346
  writable: { enumerable: true }
4349
4347
  });
4350
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
4351
- Object.defineProperty(TransformStream.prototype, SymbolPolyfill.toStringTag, {
4348
+ if (typeof Symbol.toStringTag === 'symbol') {
4349
+ Object.defineProperty(TransformStream.prototype, Symbol.toStringTag, {
4352
4350
  value: 'TransformStream',
4353
4351
  configurable: true
4354
4352
  });
@@ -4474,8 +4472,8 @@
4474
4472
  setFunctionName(TransformStreamDefaultController.prototype.enqueue, 'enqueue');
4475
4473
  setFunctionName(TransformStreamDefaultController.prototype.error, 'error');
4476
4474
  setFunctionName(TransformStreamDefaultController.prototype.terminate, 'terminate');
4477
- if (typeof SymbolPolyfill.toStringTag === 'symbol') {
4478
- Object.defineProperty(TransformStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
4475
+ if (typeof Symbol.toStringTag === 'symbol') {
4476
+ Object.defineProperty(TransformStreamDefaultController.prototype, Symbol.toStringTag, {
4479
4477
  value: 'TransformStreamDefaultController',
4480
4478
  configurable: true
4481
4479
  });