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 +0 -1
- package/dist/polyfill.es2018.js +49 -51
- package/dist/polyfill.es2018.js.map +1 -1
- package/dist/polyfill.es2018.min.js +2 -2
- package/dist/polyfill.es2018.min.js.map +1 -1
- package/dist/polyfill.es2018.mjs +49 -51
- package/dist/polyfill.es2018.mjs.map +1 -1
- package/dist/polyfill.es6.js +180 -186
- package/dist/polyfill.es6.js.map +1 -1
- package/dist/polyfill.es6.min.js +2 -2
- package/dist/polyfill.es6.min.js.map +1 -1
- package/dist/polyfill.es6.mjs +180 -186
- package/dist/polyfill.es6.mjs.map +1 -1
- package/dist/polyfill.js +139 -140
- package/dist/polyfill.js.map +1 -1
- package/dist/polyfill.min.js +2 -2
- package/dist/polyfill.min.js.map +1 -1
- package/dist/polyfill.mjs +139 -140
- package/dist/polyfill.mjs.map +1 -1
- package/dist/ponyfill.es2018.js +49 -51
- package/dist/ponyfill.es2018.js.map +1 -1
- package/dist/ponyfill.es2018.mjs +49 -51
- package/dist/ponyfill.es2018.mjs.map +1 -1
- package/dist/ponyfill.es6.js +180 -186
- package/dist/ponyfill.es6.js.map +1 -1
- package/dist/ponyfill.es6.mjs +180 -186
- package/dist/ponyfill.es6.mjs.map +1 -1
- package/dist/ponyfill.js +139 -140
- package/dist/ponyfill.js.map +1 -1
- package/dist/ponyfill.mjs +139 -140
- package/dist/ponyfill.mjs.map +1 -1
- package/dist/types/polyfill.d.ts +24 -0
- package/dist/types/ponyfill.d.ts +3 -3
- package/dist/types/ts3.6/polyfill.d.ts +28 -0
- package/dist/types/ts3.6/ponyfill.d.ts +3 -3
- package/package.json +1 -1
package/dist/ponyfill.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* web-streams-polyfill v3.3.
|
|
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
|
|
@@ -635,22 +635,137 @@ function defaultReaderBrandCheckException(name) {
|
|
|
635
635
|
return new TypeError("ReadableStreamDefaultReader.prototype.".concat(name, " can only be used on a ReadableStreamDefaultReader"));
|
|
636
636
|
}
|
|
637
637
|
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}
|
|
638
|
+
var _a$1, _b, _c;
|
|
639
|
+
function CreateArrayFromList(elements) {
|
|
640
|
+
// We use arrays to represent lists, so this is basically a no-op.
|
|
641
|
+
// Do a slice though just in case we happen to depend on the unique-ness.
|
|
642
|
+
return elements.slice();
|
|
643
|
+
}
|
|
644
|
+
function CopyDataBlockBytes(dest, destOffset, src, srcOffset, n) {
|
|
645
|
+
new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
|
|
646
|
+
}
|
|
647
|
+
var TransferArrayBuffer = function (O) {
|
|
648
|
+
if (typeof O.transfer === 'function') {
|
|
649
|
+
TransferArrayBuffer = function (buffer) { return buffer.transfer(); };
|
|
650
|
+
}
|
|
651
|
+
else if (typeof structuredClone === 'function') {
|
|
652
|
+
TransferArrayBuffer = function (buffer) { return structuredClone(buffer, { transfer: [buffer] }); };
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
// Not implemented correctly
|
|
656
|
+
TransferArrayBuffer = function (buffer) { return buffer; };
|
|
657
|
+
}
|
|
658
|
+
return TransferArrayBuffer(O);
|
|
659
|
+
};
|
|
660
|
+
var IsDetachedBuffer = function (O) {
|
|
661
|
+
if (typeof O.detached === 'boolean') {
|
|
662
|
+
IsDetachedBuffer = function (buffer) { return buffer.detached; };
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
// Not implemented correctly
|
|
666
|
+
IsDetachedBuffer = function (buffer) { return buffer.byteLength === 0; };
|
|
667
|
+
}
|
|
668
|
+
return IsDetachedBuffer(O);
|
|
669
|
+
};
|
|
670
|
+
function ArrayBufferSlice(buffer, begin, end) {
|
|
671
|
+
// ArrayBuffer.prototype.slice is not available on IE10
|
|
672
|
+
// https://www.caniuse.com/mdn-javascript_builtins_arraybuffer_slice
|
|
673
|
+
if (buffer.slice) {
|
|
674
|
+
return buffer.slice(begin, end);
|
|
675
|
+
}
|
|
676
|
+
var length = end - begin;
|
|
677
|
+
var slice = new ArrayBuffer(length);
|
|
678
|
+
CopyDataBlockBytes(slice, 0, buffer, begin, length);
|
|
679
|
+
return slice;
|
|
680
|
+
}
|
|
681
|
+
function GetMethod(receiver, prop) {
|
|
682
|
+
var func = receiver[prop];
|
|
683
|
+
if (func === undefined || func === null) {
|
|
684
|
+
return undefined;
|
|
685
|
+
}
|
|
686
|
+
if (typeof func !== 'function') {
|
|
687
|
+
throw new TypeError("".concat(String(prop), " is not a function"));
|
|
688
|
+
}
|
|
689
|
+
return func;
|
|
690
|
+
}
|
|
691
|
+
function CreateAsyncFromSyncIterator(syncIteratorRecord) {
|
|
692
|
+
// Instead of re-implementing CreateAsyncFromSyncIterator and %AsyncFromSyncIteratorPrototype%,
|
|
693
|
+
// we use yield* inside an async generator function to achieve the same result.
|
|
694
|
+
var _a;
|
|
695
|
+
// Wrap the sync iterator inside a sync iterable, so we can use it with yield*.
|
|
696
|
+
var syncIterable = (_a = {},
|
|
697
|
+
_a[SymbolPolyfill.iterator] = function () { return syncIteratorRecord.iterator; },
|
|
650
698
|
_a);
|
|
651
|
-
|
|
699
|
+
// Create an async generator function and immediately invoke it.
|
|
700
|
+
var asyncIterator = (function () {
|
|
701
|
+
return __asyncGenerator(this, arguments, function () {
|
|
702
|
+
return __generator(this, function (_a) {
|
|
703
|
+
switch (_a.label) {
|
|
704
|
+
case 0: return [5 /*yield**/, __values(__asyncDelegator(__asyncValues(syncIterable)))];
|
|
705
|
+
case 1: return [4 /*yield*/, __await.apply(void 0, [_a.sent()])];
|
|
706
|
+
case 2: return [4 /*yield*/, __await.apply(void 0, [_a.sent()])];
|
|
707
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
});
|
|
711
|
+
}());
|
|
712
|
+
// Return as an async iterator record.
|
|
713
|
+
var nextMethod = asyncIterator.next;
|
|
714
|
+
return { iterator: asyncIterator, nextMethod: nextMethod, done: false };
|
|
715
|
+
}
|
|
716
|
+
// Aligns with core-js/modules/es.symbol.async-iterator.js
|
|
717
|
+
var SymbolAsyncIterator = (_c = (_a$1 = SymbolPolyfill.asyncIterator) !== null && _a$1 !== void 0 ? _a$1 : (_b = SymbolPolyfill.for) === null || _b === void 0 ? void 0 : _b.call(SymbolPolyfill, 'Symbol.asyncIterator')) !== null && _c !== void 0 ? _c : '@@asyncIterator';
|
|
718
|
+
function GetIterator(obj, hint, method) {
|
|
719
|
+
if (hint === void 0) { hint = 'sync'; }
|
|
720
|
+
if (method === undefined) {
|
|
721
|
+
if (hint === 'async') {
|
|
722
|
+
method = GetMethod(obj, SymbolAsyncIterator);
|
|
723
|
+
if (method === undefined) {
|
|
724
|
+
var syncMethod = GetMethod(obj, SymbolPolyfill.iterator);
|
|
725
|
+
var syncIteratorRecord = GetIterator(obj, 'sync', syncMethod);
|
|
726
|
+
return CreateAsyncFromSyncIterator(syncIteratorRecord);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
else {
|
|
730
|
+
method = GetMethod(obj, SymbolPolyfill.iterator);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
if (method === undefined) {
|
|
734
|
+
throw new TypeError('The object is not iterable');
|
|
735
|
+
}
|
|
736
|
+
var iterator = reflectCall(method, obj, []);
|
|
737
|
+
if (!typeIsObject(iterator)) {
|
|
738
|
+
throw new TypeError('The iterator method must return an object');
|
|
739
|
+
}
|
|
740
|
+
var nextMethod = iterator.next;
|
|
741
|
+
return { iterator: iterator, nextMethod: nextMethod, done: false };
|
|
742
|
+
}
|
|
743
|
+
function IteratorNext(iteratorRecord) {
|
|
744
|
+
var result = reflectCall(iteratorRecord.nextMethod, iteratorRecord.iterator, []);
|
|
745
|
+
if (!typeIsObject(result)) {
|
|
746
|
+
throw new TypeError('The iterator.next() method must return an object');
|
|
747
|
+
}
|
|
748
|
+
return result;
|
|
749
|
+
}
|
|
750
|
+
function IteratorComplete(iterResult) {
|
|
751
|
+
return Boolean(iterResult.done);
|
|
752
|
+
}
|
|
753
|
+
function IteratorValue(iterResult) {
|
|
754
|
+
return iterResult.value;
|
|
652
755
|
}
|
|
653
756
|
|
|
757
|
+
/// <reference lib="es2018.asynciterable" />
|
|
758
|
+
var _a;
|
|
759
|
+
// We cannot access %AsyncIteratorPrototype% without non-ES2018 syntax, but we can re-create it.
|
|
760
|
+
var AsyncIteratorPrototype = (_a = {},
|
|
761
|
+
// 25.1.3.1 %AsyncIteratorPrototype% [ @@asyncIterator ] ( )
|
|
762
|
+
// https://tc39.github.io/ecma262/#sec-asynciteratorprototype-asynciterator
|
|
763
|
+
_a[SymbolAsyncIterator] = function () {
|
|
764
|
+
return this;
|
|
765
|
+
},
|
|
766
|
+
_a);
|
|
767
|
+
Object.defineProperty(AsyncIteratorPrototype, SymbolAsyncIterator, { enumerable: false });
|
|
768
|
+
|
|
654
769
|
/// <reference lib="es2018.asynciterable" />
|
|
655
770
|
var ReadableStreamAsyncIteratorImpl = /** @class */ (function () {
|
|
656
771
|
function ReadableStreamAsyncIteratorImpl(reader, preventCancel) {
|
|
@@ -739,9 +854,7 @@ var ReadableStreamAsyncIteratorPrototype = {
|
|
|
739
854
|
return this._asyncIteratorImpl.return(value);
|
|
740
855
|
}
|
|
741
856
|
};
|
|
742
|
-
|
|
743
|
-
Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype);
|
|
744
|
-
}
|
|
857
|
+
Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype);
|
|
745
858
|
// Abstract operations for the ReadableStream.
|
|
746
859
|
function AcquireReadableStreamAsyncIterator(stream, preventCancel) {
|
|
747
860
|
var reader = AcquireReadableStreamDefaultReader(stream);
|
|
@@ -778,122 +891,6 @@ var NumberIsNaN = Number.isNaN || function (x) {
|
|
|
778
891
|
return x !== x;
|
|
779
892
|
};
|
|
780
893
|
|
|
781
|
-
function CreateArrayFromList(elements) {
|
|
782
|
-
// We use arrays to represent lists, so this is basically a no-op.
|
|
783
|
-
// Do a slice though just in case we happen to depend on the unique-ness.
|
|
784
|
-
return elements.slice();
|
|
785
|
-
}
|
|
786
|
-
function CopyDataBlockBytes(dest, destOffset, src, srcOffset, n) {
|
|
787
|
-
new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
|
|
788
|
-
}
|
|
789
|
-
var TransferArrayBuffer = function (O) {
|
|
790
|
-
if (typeof O.transfer === 'function') {
|
|
791
|
-
TransferArrayBuffer = function (buffer) { return buffer.transfer(); };
|
|
792
|
-
}
|
|
793
|
-
else if (typeof structuredClone === 'function') {
|
|
794
|
-
TransferArrayBuffer = function (buffer) { return structuredClone(buffer, { transfer: [buffer] }); };
|
|
795
|
-
}
|
|
796
|
-
else {
|
|
797
|
-
// Not implemented correctly
|
|
798
|
-
TransferArrayBuffer = function (buffer) { return buffer; };
|
|
799
|
-
}
|
|
800
|
-
return TransferArrayBuffer(O);
|
|
801
|
-
};
|
|
802
|
-
var IsDetachedBuffer = function (O) {
|
|
803
|
-
if (typeof O.detached === 'boolean') {
|
|
804
|
-
IsDetachedBuffer = function (buffer) { return buffer.detached; };
|
|
805
|
-
}
|
|
806
|
-
else {
|
|
807
|
-
// Not implemented correctly
|
|
808
|
-
IsDetachedBuffer = function (buffer) { return buffer.byteLength === 0; };
|
|
809
|
-
}
|
|
810
|
-
return IsDetachedBuffer(O);
|
|
811
|
-
};
|
|
812
|
-
function ArrayBufferSlice(buffer, begin, end) {
|
|
813
|
-
// ArrayBuffer.prototype.slice is not available on IE10
|
|
814
|
-
// https://www.caniuse.com/mdn-javascript_builtins_arraybuffer_slice
|
|
815
|
-
if (buffer.slice) {
|
|
816
|
-
return buffer.slice(begin, end);
|
|
817
|
-
}
|
|
818
|
-
var length = end - begin;
|
|
819
|
-
var slice = new ArrayBuffer(length);
|
|
820
|
-
CopyDataBlockBytes(slice, 0, buffer, begin, length);
|
|
821
|
-
return slice;
|
|
822
|
-
}
|
|
823
|
-
function GetMethod(receiver, prop) {
|
|
824
|
-
var func = receiver[prop];
|
|
825
|
-
if (func === undefined || func === null) {
|
|
826
|
-
return undefined;
|
|
827
|
-
}
|
|
828
|
-
if (typeof func !== 'function') {
|
|
829
|
-
throw new TypeError("".concat(String(prop), " is not a function"));
|
|
830
|
-
}
|
|
831
|
-
return func;
|
|
832
|
-
}
|
|
833
|
-
function CreateAsyncFromSyncIterator(syncIteratorRecord) {
|
|
834
|
-
// Instead of re-implementing CreateAsyncFromSyncIterator and %AsyncFromSyncIteratorPrototype%,
|
|
835
|
-
// we use yield* inside an async generator function to achieve the same result.
|
|
836
|
-
var _a;
|
|
837
|
-
// Wrap the sync iterator inside a sync iterable, so we can use it with yield*.
|
|
838
|
-
var syncIterable = (_a = {},
|
|
839
|
-
_a[SymbolPolyfill.iterator] = function () { return syncIteratorRecord.iterator; },
|
|
840
|
-
_a);
|
|
841
|
-
// Create an async generator function and immediately invoke it.
|
|
842
|
-
var asyncIterator = (function () {
|
|
843
|
-
return __asyncGenerator(this, arguments, function () {
|
|
844
|
-
return __generator(this, function (_a) {
|
|
845
|
-
switch (_a.label) {
|
|
846
|
-
case 0: return [5 /*yield**/, __values(__asyncDelegator(__asyncValues(syncIterable)))];
|
|
847
|
-
case 1: return [4 /*yield*/, __await.apply(void 0, [_a.sent()])];
|
|
848
|
-
case 2: return [4 /*yield*/, __await.apply(void 0, [_a.sent()])];
|
|
849
|
-
case 3: return [2 /*return*/, _a.sent()];
|
|
850
|
-
}
|
|
851
|
-
});
|
|
852
|
-
});
|
|
853
|
-
}());
|
|
854
|
-
// Return as an async iterator record.
|
|
855
|
-
var nextMethod = asyncIterator.next;
|
|
856
|
-
return { iterator: asyncIterator, nextMethod: nextMethod, done: false };
|
|
857
|
-
}
|
|
858
|
-
function GetIterator(obj, hint, method) {
|
|
859
|
-
if (hint === void 0) { hint = 'sync'; }
|
|
860
|
-
if (method === undefined) {
|
|
861
|
-
if (hint === 'async') {
|
|
862
|
-
method = GetMethod(obj, SymbolPolyfill.asyncIterator);
|
|
863
|
-
if (method === undefined) {
|
|
864
|
-
var syncMethod = GetMethod(obj, SymbolPolyfill.iterator);
|
|
865
|
-
var syncIteratorRecord = GetIterator(obj, 'sync', syncMethod);
|
|
866
|
-
return CreateAsyncFromSyncIterator(syncIteratorRecord);
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
else {
|
|
870
|
-
method = GetMethod(obj, SymbolPolyfill.iterator);
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
if (method === undefined) {
|
|
874
|
-
throw new TypeError('The object is not iterable');
|
|
875
|
-
}
|
|
876
|
-
var iterator = reflectCall(method, obj, []);
|
|
877
|
-
if (!typeIsObject(iterator)) {
|
|
878
|
-
throw new TypeError('The iterator method must return an object');
|
|
879
|
-
}
|
|
880
|
-
var nextMethod = iterator.next;
|
|
881
|
-
return { iterator: iterator, nextMethod: nextMethod, done: false };
|
|
882
|
-
}
|
|
883
|
-
function IteratorNext(iteratorRecord) {
|
|
884
|
-
var result = reflectCall(iteratorRecord.nextMethod, iteratorRecord.iterator, []);
|
|
885
|
-
if (!typeIsObject(result)) {
|
|
886
|
-
throw new TypeError('The iterator.next() method must return an object');
|
|
887
|
-
}
|
|
888
|
-
return result;
|
|
889
|
-
}
|
|
890
|
-
function IteratorComplete(iterResult) {
|
|
891
|
-
return Boolean(iterResult.done);
|
|
892
|
-
}
|
|
893
|
-
function IteratorValue(iterResult) {
|
|
894
|
-
return iterResult.value;
|
|
895
|
-
}
|
|
896
|
-
|
|
897
894
|
function IsNonNegativeNumber(v) {
|
|
898
895
|
if (typeof v !== 'number') {
|
|
899
896
|
return false;
|
|
@@ -4177,6 +4174,10 @@ var ReadableStream = /** @class */ (function () {
|
|
|
4177
4174
|
var options = convertIteratorOptions(rawOptions, 'First parameter');
|
|
4178
4175
|
return AcquireReadableStreamAsyncIterator(this, options.preventCancel);
|
|
4179
4176
|
};
|
|
4177
|
+
ReadableStream.prototype[SymbolAsyncIterator] = function (options) {
|
|
4178
|
+
// Stub implementation, overridden below
|
|
4179
|
+
return this.values(options);
|
|
4180
|
+
};
|
|
4180
4181
|
/**
|
|
4181
4182
|
* Creates a new ReadableStream wrapping the provided iterable or async iterable.
|
|
4182
4183
|
*
|
|
@@ -4213,13 +4214,11 @@ if (typeof SymbolPolyfill.toStringTag === 'symbol') {
|
|
|
4213
4214
|
configurable: true
|
|
4214
4215
|
});
|
|
4215
4216
|
}
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
});
|
|
4222
|
-
}
|
|
4217
|
+
Object.defineProperty(ReadableStream.prototype, SymbolAsyncIterator, {
|
|
4218
|
+
value: ReadableStream.prototype.values,
|
|
4219
|
+
writable: true,
|
|
4220
|
+
configurable: true
|
|
4221
|
+
});
|
|
4223
4222
|
// Abstract operations for the ReadableStream.
|
|
4224
4223
|
// Throws if and only if startAlgorithm throws.
|
|
4225
4224
|
function CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm) {
|