web-streams-polyfill 3.0.1 → 3.1.1
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/CHANGELOG.md +22 -0
- package/README.md +10 -6
- package/dist/polyfill.es2018.js +458 -124
- package/dist/polyfill.es2018.js.map +1 -1
- package/dist/polyfill.es2018.min.js +1 -1
- package/dist/polyfill.es2018.min.js.map +1 -1
- package/dist/polyfill.es2018.mjs +457 -123
- package/dist/polyfill.es2018.mjs.map +1 -1
- package/dist/polyfill.es6.js +458 -124
- package/dist/polyfill.es6.js.map +1 -1
- package/dist/polyfill.es6.min.js +1 -1
- package/dist/polyfill.es6.min.js.map +1 -1
- package/dist/polyfill.es6.mjs +457 -123
- package/dist/polyfill.es6.mjs.map +1 -1
- package/dist/polyfill.js +466 -124
- package/dist/polyfill.js.map +1 -1
- package/dist/polyfill.min.js +1 -1
- package/dist/polyfill.min.js.map +1 -1
- package/dist/polyfill.mjs +465 -123
- package/dist/polyfill.mjs.map +1 -1
- package/dist/ponyfill.es2018.js +458 -124
- package/dist/ponyfill.es2018.js.map +1 -1
- package/dist/ponyfill.es2018.mjs +457 -123
- package/dist/ponyfill.es2018.mjs.map +1 -1
- package/dist/ponyfill.es6.js +458 -124
- package/dist/ponyfill.es6.js.map +1 -1
- package/dist/ponyfill.es6.mjs +457 -123
- package/dist/ponyfill.es6.mjs.map +1 -1
- package/dist/ponyfill.js +466 -124
- package/dist/ponyfill.js.map +1 -1
- package/dist/ponyfill.mjs +465 -123
- package/dist/ponyfill.mjs.map +1 -1
- package/dist/types/polyfill.d.ts +26 -10
- package/dist/types/ts3.6/polyfill.d.ts +26 -10
- package/dist/types/tsdoc-metadata.json +1 -1
- package/package.json +16 -16
package/dist/ponyfill.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* web-streams-polyfill v3.
|
|
2
|
+
* web-streams-polyfill v3.1.1
|
|
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
|
-
|
|
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 =
|
|
30
|
+
var rethrowAssertionErrorRejection = noop;
|
|
31
31
|
|
|
32
32
|
var originalPromise = Promise;
|
|
33
33
|
var originalPromiseThen = Promise.prototype.then;
|
|
@@ -499,7 +499,7 @@ function IsReadableStreamDefaultReader(x) {
|
|
|
499
499
|
if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {
|
|
500
500
|
return false;
|
|
501
501
|
}
|
|
502
|
-
return
|
|
502
|
+
return x instanceof ReadableStreamDefaultReader;
|
|
503
503
|
}
|
|
504
504
|
function ReadableStreamDefaultReaderRead(reader, readRequest) {
|
|
505
505
|
var stream = reader._ownerReadableStream;
|
|
@@ -647,7 +647,14 @@ function IsReadableStreamAsyncIterator(x) {
|
|
|
647
647
|
if (!Object.prototype.hasOwnProperty.call(x, '_asyncIteratorImpl')) {
|
|
648
648
|
return false;
|
|
649
649
|
}
|
|
650
|
-
|
|
650
|
+
try {
|
|
651
|
+
// noinspection SuspiciousTypeOfGuard
|
|
652
|
+
return x._asyncIteratorImpl instanceof
|
|
653
|
+
ReadableStreamAsyncIteratorImpl;
|
|
654
|
+
}
|
|
655
|
+
catch (_a) {
|
|
656
|
+
return false;
|
|
657
|
+
}
|
|
651
658
|
}
|
|
652
659
|
// Helper functions for the ReadableStream.
|
|
653
660
|
function streamAsyncIteratorBrandCheckException(name) {
|
|
@@ -661,15 +668,35 @@ var NumberIsNaN = Number.isNaN || function (x) {
|
|
|
661
668
|
return x !== x;
|
|
662
669
|
};
|
|
663
670
|
|
|
664
|
-
function
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
671
|
+
function CreateArrayFromList(elements) {
|
|
672
|
+
// We use arrays to represent lists, so this is basically a no-op.
|
|
673
|
+
// Do a slice though just in case we happen to depend on the unique-ness.
|
|
674
|
+
return elements.slice();
|
|
675
|
+
}
|
|
676
|
+
function CopyDataBlockBytes(dest, destOffset, src, srcOffset, n) {
|
|
677
|
+
new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
|
|
678
|
+
}
|
|
679
|
+
// Not implemented correctly
|
|
680
|
+
function TransferArrayBuffer(O) {
|
|
681
|
+
return O;
|
|
682
|
+
}
|
|
683
|
+
// Not implemented correctly
|
|
684
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
685
|
+
function IsDetachedBuffer(O) {
|
|
686
|
+
return false;
|
|
687
|
+
}
|
|
688
|
+
function ArrayBufferSlice(buffer, begin, end) {
|
|
689
|
+
// ArrayBuffer.prototype.slice is not available on IE10
|
|
690
|
+
// https://www.caniuse.com/mdn-javascript_builtins_arraybuffer_slice
|
|
691
|
+
if (buffer.slice) {
|
|
692
|
+
return buffer.slice(begin, end);
|
|
670
693
|
}
|
|
671
|
-
|
|
694
|
+
var length = end - begin;
|
|
695
|
+
var slice = new ArrayBuffer(length);
|
|
696
|
+
CopyDataBlockBytes(slice, 0, buffer, begin, length);
|
|
697
|
+
return slice;
|
|
672
698
|
}
|
|
699
|
+
|
|
673
700
|
function IsNonNegativeNumber(v) {
|
|
674
701
|
if (typeof v !== 'number') {
|
|
675
702
|
return false;
|
|
@@ -682,6 +709,10 @@ function IsNonNegativeNumber(v) {
|
|
|
682
709
|
}
|
|
683
710
|
return true;
|
|
684
711
|
}
|
|
712
|
+
function CloneAsUint8Array(O) {
|
|
713
|
+
var buffer = ArrayBufferSlice(O.buffer, O.byteOffset, O.byteOffset + O.byteLength);
|
|
714
|
+
return new Uint8Array(buffer);
|
|
715
|
+
}
|
|
685
716
|
|
|
686
717
|
function DequeueValue(container) {
|
|
687
718
|
var pair = container._queue.shift();
|
|
@@ -692,8 +723,7 @@ function DequeueValue(container) {
|
|
|
692
723
|
return pair.value;
|
|
693
724
|
}
|
|
694
725
|
function EnqueueValueWithSize(container, value, size) {
|
|
695
|
-
size
|
|
696
|
-
if (!IsFiniteNonNegativeNumber(size)) {
|
|
726
|
+
if (!IsNonNegativeNumber(size) || size === Infinity) {
|
|
697
727
|
throw new RangeError('Size must be a finite, non-NaN, non-negative number.');
|
|
698
728
|
}
|
|
699
729
|
container._queue.push({ value: value, size: size });
|
|
@@ -708,23 +738,6 @@ function ResetQueue(container) {
|
|
|
708
738
|
container._queueTotalSize = 0;
|
|
709
739
|
}
|
|
710
740
|
|
|
711
|
-
function CreateArrayFromList(elements) {
|
|
712
|
-
// We use arrays to represent lists, so this is basically a no-op.
|
|
713
|
-
// Do a slice though just in case we happen to depend on the unique-ness.
|
|
714
|
-
return elements.slice();
|
|
715
|
-
}
|
|
716
|
-
function CopyDataBlockBytes(dest, destOffset, src, srcOffset, n) {
|
|
717
|
-
new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
|
|
718
|
-
}
|
|
719
|
-
// Not implemented correctly
|
|
720
|
-
function TransferArrayBuffer(O) {
|
|
721
|
-
return O;
|
|
722
|
-
}
|
|
723
|
-
// Not implemented correctly
|
|
724
|
-
function IsDetachedBuffer(O) {
|
|
725
|
-
return false;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
741
|
/**
|
|
729
742
|
* A pull-into request in a {@link ReadableByteStreamController}.
|
|
730
743
|
*
|
|
@@ -767,15 +780,10 @@ var ReadableStreamBYOBRequest = /** @class */ (function () {
|
|
|
767
780
|
if (!ArrayBuffer.isView(view)) {
|
|
768
781
|
throw new TypeError('You can only respond with array buffer views');
|
|
769
782
|
}
|
|
770
|
-
if (view.byteLength === 0) {
|
|
771
|
-
throw new TypeError('chunk must have non-zero byteLength');
|
|
772
|
-
}
|
|
773
|
-
if (view.buffer.byteLength === 0) {
|
|
774
|
-
throw new TypeError("chunk's buffer must have non-zero byteLength");
|
|
775
|
-
}
|
|
776
783
|
if (this._associatedReadableByteStreamController === undefined) {
|
|
777
784
|
throw new TypeError('This BYOB request has been invalidated');
|
|
778
785
|
}
|
|
786
|
+
if (IsDetachedBuffer(view.buffer)) ;
|
|
779
787
|
ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
|
|
780
788
|
};
|
|
781
789
|
return ReadableStreamBYOBRequest;
|
|
@@ -808,14 +816,7 @@ var ReadableByteStreamController = /** @class */ (function () {
|
|
|
808
816
|
if (!IsReadableByteStreamController(this)) {
|
|
809
817
|
throw byteStreamControllerBrandCheckException('byobRequest');
|
|
810
818
|
}
|
|
811
|
-
|
|
812
|
-
var firstDescriptor = this._pendingPullIntos.peek();
|
|
813
|
-
var view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
|
|
814
|
-
var byobRequest = Object.create(ReadableStreamBYOBRequest.prototype);
|
|
815
|
-
SetUpReadableStreamBYOBRequest(byobRequest, this, view);
|
|
816
|
-
this._byobRequest = byobRequest;
|
|
817
|
-
}
|
|
818
|
-
return this._byobRequest;
|
|
819
|
+
return ReadableByteStreamControllerGetBYOBRequest(this);
|
|
819
820
|
},
|
|
820
821
|
enumerable: false,
|
|
821
822
|
configurable: true
|
|
@@ -886,10 +887,7 @@ var ReadableByteStreamController = /** @class */ (function () {
|
|
|
886
887
|
};
|
|
887
888
|
/** @internal */
|
|
888
889
|
ReadableByteStreamController.prototype[CancelSteps] = function (reason) {
|
|
889
|
-
|
|
890
|
-
var firstDescriptor = this._pendingPullIntos.peek();
|
|
891
|
-
firstDescriptor.bytesFilled = 0;
|
|
892
|
-
}
|
|
890
|
+
ReadableByteStreamControllerClearPendingPullIntos(this);
|
|
893
891
|
ResetQueue(this);
|
|
894
892
|
var result = this._cancelAlgorithm(reason);
|
|
895
893
|
ReadableByteStreamControllerClearAlgorithms(this);
|
|
@@ -918,6 +916,7 @@ var ReadableByteStreamController = /** @class */ (function () {
|
|
|
918
916
|
}
|
|
919
917
|
var pullIntoDescriptor = {
|
|
920
918
|
buffer: buffer,
|
|
919
|
+
bufferByteLength: autoAllocateChunkSize,
|
|
921
920
|
byteOffset: 0,
|
|
922
921
|
byteLength: autoAllocateChunkSize,
|
|
923
922
|
bytesFilled: 0,
|
|
@@ -953,7 +952,7 @@ function IsReadableByteStreamController(x) {
|
|
|
953
952
|
if (!Object.prototype.hasOwnProperty.call(x, '_controlledReadableByteStream')) {
|
|
954
953
|
return false;
|
|
955
954
|
}
|
|
956
|
-
return
|
|
955
|
+
return x instanceof ReadableByteStreamController;
|
|
957
956
|
}
|
|
958
957
|
function IsReadableStreamBYOBRequest(x) {
|
|
959
958
|
if (!typeIsObject(x)) {
|
|
@@ -962,7 +961,7 @@ function IsReadableStreamBYOBRequest(x) {
|
|
|
962
961
|
if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) {
|
|
963
962
|
return false;
|
|
964
963
|
}
|
|
965
|
-
return
|
|
964
|
+
return x instanceof ReadableStreamBYOBRequest;
|
|
966
965
|
}
|
|
967
966
|
function ReadableByteStreamControllerCallPullIfNeeded(controller) {
|
|
968
967
|
var shouldPull = ReadableByteStreamControllerShouldCallPull(controller);
|
|
@@ -1044,7 +1043,6 @@ function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller,
|
|
|
1044
1043
|
return ready;
|
|
1045
1044
|
}
|
|
1046
1045
|
function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {
|
|
1047
|
-
ReadableByteStreamControllerInvalidateBYOBRequest(controller);
|
|
1048
1046
|
pullIntoDescriptor.bytesFilled += size;
|
|
1049
1047
|
}
|
|
1050
1048
|
function ReadableByteStreamControllerHandleQueueDrain(controller) {
|
|
@@ -1083,9 +1081,15 @@ function ReadableByteStreamControllerPullInto(controller, view, readIntoRequest)
|
|
|
1083
1081
|
elementSize = view.constructor.BYTES_PER_ELEMENT;
|
|
1084
1082
|
}
|
|
1085
1083
|
var ctor = view.constructor;
|
|
1084
|
+
// try {
|
|
1086
1085
|
var buffer = TransferArrayBuffer(view.buffer);
|
|
1086
|
+
// } catch (e) {
|
|
1087
|
+
// readIntoRequest._errorSteps(e);
|
|
1088
|
+
// return;
|
|
1089
|
+
// }
|
|
1087
1090
|
var pullIntoDescriptor = {
|
|
1088
1091
|
buffer: buffer,
|
|
1092
|
+
bufferByteLength: buffer.byteLength,
|
|
1089
1093
|
byteOffset: view.byteOffset,
|
|
1090
1094
|
byteLength: view.byteLength,
|
|
1091
1095
|
bytesFilled: 0,
|
|
@@ -1125,7 +1129,6 @@ function ReadableByteStreamControllerPullInto(controller, view, readIntoRequest)
|
|
|
1125
1129
|
ReadableByteStreamControllerCallPullIfNeeded(controller);
|
|
1126
1130
|
}
|
|
1127
1131
|
function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
|
|
1128
|
-
firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
|
|
1129
1132
|
var stream = controller._controlledReadableByteStream;
|
|
1130
1133
|
if (ReadableStreamHasBYOBReader(stream)) {
|
|
1131
1134
|
while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
|
|
@@ -1135,34 +1138,27 @@ function ReadableByteStreamControllerRespondInClosedState(controller, firstDescr
|
|
|
1135
1138
|
}
|
|
1136
1139
|
}
|
|
1137
1140
|
function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
|
|
1138
|
-
if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) {
|
|
1139
|
-
throw new RangeError('bytesWritten out of range');
|
|
1140
|
-
}
|
|
1141
1141
|
ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
|
|
1142
1142
|
if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
|
|
1143
|
-
// TODO: Figure out whether we should detach the buffer or not here.
|
|
1144
1143
|
return;
|
|
1145
1144
|
}
|
|
1146
1145
|
ReadableByteStreamControllerShiftPendingPullInto(controller);
|
|
1147
1146
|
var remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
|
|
1148
1147
|
if (remainderSize > 0) {
|
|
1149
1148
|
var end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
|
|
1150
|
-
var remainder = pullIntoDescriptor.buffer
|
|
1149
|
+
var remainder = ArrayBufferSlice(pullIntoDescriptor.buffer, end - remainderSize, end);
|
|
1151
1150
|
ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
|
|
1152
1151
|
}
|
|
1153
|
-
pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
|
|
1154
1152
|
pullIntoDescriptor.bytesFilled -= remainderSize;
|
|
1155
1153
|
ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor);
|
|
1156
1154
|
ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
|
|
1157
1155
|
}
|
|
1158
1156
|
function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
|
|
1159
1157
|
var firstDescriptor = controller._pendingPullIntos.peek();
|
|
1158
|
+
ReadableByteStreamControllerInvalidateBYOBRequest(controller);
|
|
1160
1159
|
var state = controller._controlledReadableByteStream._state;
|
|
1161
1160
|
if (state === 'closed') {
|
|
1162
|
-
|
|
1163
|
-
throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
|
|
1164
|
-
}
|
|
1165
|
-
ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
|
|
1161
|
+
ReadableByteStreamControllerRespondInClosedState(controller);
|
|
1166
1162
|
}
|
|
1167
1163
|
else {
|
|
1168
1164
|
ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
|
|
@@ -1171,7 +1167,6 @@ function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
|
|
|
1171
1167
|
}
|
|
1172
1168
|
function ReadableByteStreamControllerShiftPendingPullInto(controller) {
|
|
1173
1169
|
var descriptor = controller._pendingPullIntos.shift();
|
|
1174
|
-
ReadableByteStreamControllerInvalidateBYOBRequest(controller);
|
|
1175
1170
|
return descriptor;
|
|
1176
1171
|
}
|
|
1177
1172
|
function ReadableByteStreamControllerShouldCallPull(controller) {
|
|
@@ -1231,6 +1226,12 @@ function ReadableByteStreamControllerEnqueue(controller, chunk) {
|
|
|
1231
1226
|
var byteOffset = chunk.byteOffset;
|
|
1232
1227
|
var byteLength = chunk.byteLength;
|
|
1233
1228
|
var transferredBuffer = TransferArrayBuffer(buffer);
|
|
1229
|
+
if (controller._pendingPullIntos.length > 0) {
|
|
1230
|
+
var firstPendingPullInto = controller._pendingPullIntos.peek();
|
|
1231
|
+
if (IsDetachedBuffer(firstPendingPullInto.buffer)) ;
|
|
1232
|
+
firstPendingPullInto.buffer = TransferArrayBuffer(firstPendingPullInto.buffer);
|
|
1233
|
+
}
|
|
1234
|
+
ReadableByteStreamControllerInvalidateBYOBRequest(controller);
|
|
1234
1235
|
if (ReadableStreamHasDefaultReader(stream)) {
|
|
1235
1236
|
if (ReadableStreamGetNumReadRequests(stream) === 0) {
|
|
1236
1237
|
ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
|
|
@@ -1260,6 +1261,16 @@ function ReadableByteStreamControllerError(controller, e) {
|
|
|
1260
1261
|
ReadableByteStreamControllerClearAlgorithms(controller);
|
|
1261
1262
|
ReadableStreamError(stream, e);
|
|
1262
1263
|
}
|
|
1264
|
+
function ReadableByteStreamControllerGetBYOBRequest(controller) {
|
|
1265
|
+
if (controller._byobRequest === null && controller._pendingPullIntos.length > 0) {
|
|
1266
|
+
var firstDescriptor = controller._pendingPullIntos.peek();
|
|
1267
|
+
var view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
|
|
1268
|
+
var byobRequest = Object.create(ReadableStreamBYOBRequest.prototype);
|
|
1269
|
+
SetUpReadableStreamBYOBRequest(byobRequest, controller, view);
|
|
1270
|
+
controller._byobRequest = byobRequest;
|
|
1271
|
+
}
|
|
1272
|
+
return controller._byobRequest;
|
|
1273
|
+
}
|
|
1263
1274
|
function ReadableByteStreamControllerGetDesiredSize(controller) {
|
|
1264
1275
|
var state = controller._controlledReadableByteStream._state;
|
|
1265
1276
|
if (state === 'errored') {
|
|
@@ -1271,21 +1282,47 @@ function ReadableByteStreamControllerGetDesiredSize(controller) {
|
|
|
1271
1282
|
return controller._strategyHWM - controller._queueTotalSize;
|
|
1272
1283
|
}
|
|
1273
1284
|
function ReadableByteStreamControllerRespond(controller, bytesWritten) {
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1285
|
+
var firstDescriptor = controller._pendingPullIntos.peek();
|
|
1286
|
+
var state = controller._controlledReadableByteStream._state;
|
|
1287
|
+
if (state === 'closed') {
|
|
1288
|
+
if (bytesWritten !== 0) {
|
|
1289
|
+
throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
else {
|
|
1293
|
+
if (bytesWritten === 0) {
|
|
1294
|
+
throw new TypeError('bytesWritten must be greater than 0 when calling respond() on a readable stream');
|
|
1295
|
+
}
|
|
1296
|
+
if (firstDescriptor.bytesFilled + bytesWritten > firstDescriptor.byteLength) {
|
|
1297
|
+
throw new RangeError('bytesWritten out of range');
|
|
1298
|
+
}
|
|
1277
1299
|
}
|
|
1300
|
+
firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
|
|
1278
1301
|
ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
|
|
1279
1302
|
}
|
|
1280
1303
|
function ReadableByteStreamControllerRespondWithNewView(controller, view) {
|
|
1281
1304
|
var firstDescriptor = controller._pendingPullIntos.peek();
|
|
1305
|
+
var state = controller._controlledReadableByteStream._state;
|
|
1306
|
+
if (state === 'closed') {
|
|
1307
|
+
if (view.byteLength !== 0) {
|
|
1308
|
+
throw new TypeError('The view\'s length must be 0 when calling respondWithNewView() on a closed stream');
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
else {
|
|
1312
|
+
if (view.byteLength === 0) {
|
|
1313
|
+
throw new TypeError('The view\'s length must be greater than 0 when calling respondWithNewView() on a readable stream');
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1282
1316
|
if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {
|
|
1283
1317
|
throw new RangeError('The region specified by view does not match byobRequest');
|
|
1284
1318
|
}
|
|
1285
|
-
if (firstDescriptor.
|
|
1319
|
+
if (firstDescriptor.bufferByteLength !== view.buffer.byteLength) {
|
|
1286
1320
|
throw new RangeError('The buffer of view has different capacity than byobRequest');
|
|
1287
1321
|
}
|
|
1288
|
-
firstDescriptor.
|
|
1322
|
+
if (firstDescriptor.bytesFilled + view.byteLength > firstDescriptor.byteLength) {
|
|
1323
|
+
throw new RangeError('The region specified by view is larger than byobRequest');
|
|
1324
|
+
}
|
|
1325
|
+
firstDescriptor.buffer = TransferArrayBuffer(view.buffer);
|
|
1289
1326
|
ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
|
|
1290
1327
|
}
|
|
1291
1328
|
function SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize) {
|
|
@@ -1327,6 +1364,9 @@ function SetUpReadableByteStreamControllerFromUnderlyingSource(stream, underlyin
|
|
|
1327
1364
|
cancelAlgorithm = function (reason) { return underlyingByteSource.cancel(reason); };
|
|
1328
1365
|
}
|
|
1329
1366
|
var autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
|
|
1367
|
+
if (autoAllocateChunkSize === 0) {
|
|
1368
|
+
throw new TypeError('autoAllocateChunkSize must be greater than 0');
|
|
1369
|
+
}
|
|
1330
1370
|
SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize);
|
|
1331
1371
|
}
|
|
1332
1372
|
function SetUpReadableStreamBYOBRequest(request, controller, view) {
|
|
@@ -1437,6 +1477,7 @@ var ReadableStreamBYOBReader = /** @class */ (function () {
|
|
|
1437
1477
|
if (view.buffer.byteLength === 0) {
|
|
1438
1478
|
return promiseRejectedWith(new TypeError("view's buffer must have non-zero byteLength"));
|
|
1439
1479
|
}
|
|
1480
|
+
if (IsDetachedBuffer(view.buffer)) ;
|
|
1440
1481
|
if (this._ownerReadableStream === undefined) {
|
|
1441
1482
|
return promiseRejectedWith(readerLockException('read from'));
|
|
1442
1483
|
}
|
|
@@ -1497,7 +1538,7 @@ function IsReadableStreamBYOBReader(x) {
|
|
|
1497
1538
|
if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) {
|
|
1498
1539
|
return false;
|
|
1499
1540
|
}
|
|
1500
|
-
return
|
|
1541
|
+
return x instanceof ReadableStreamBYOBReader;
|
|
1501
1542
|
}
|
|
1502
1543
|
function ReadableStreamBYOBReaderRead(reader, view, readIntoRequest) {
|
|
1503
1544
|
var stream = reader._ownerReadableStream;
|
|
@@ -1592,6 +1633,31 @@ function assertWritableStream(x, context) {
|
|
|
1592
1633
|
}
|
|
1593
1634
|
}
|
|
1594
1635
|
|
|
1636
|
+
function isAbortSignal(value) {
|
|
1637
|
+
if (typeof value !== 'object' || value === null) {
|
|
1638
|
+
return false;
|
|
1639
|
+
}
|
|
1640
|
+
try {
|
|
1641
|
+
return typeof value.aborted === 'boolean';
|
|
1642
|
+
}
|
|
1643
|
+
catch (_a) {
|
|
1644
|
+
// AbortSignal.prototype.aborted throws if its brand check fails
|
|
1645
|
+
return false;
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
var supportsAbortController = typeof AbortController === 'function';
|
|
1649
|
+
/**
|
|
1650
|
+
* Construct a new AbortController, if supported by the platform.
|
|
1651
|
+
*
|
|
1652
|
+
* @internal
|
|
1653
|
+
*/
|
|
1654
|
+
function createAbortController() {
|
|
1655
|
+
if (supportsAbortController) {
|
|
1656
|
+
return new AbortController();
|
|
1657
|
+
}
|
|
1658
|
+
return undefined;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1595
1661
|
/**
|
|
1596
1662
|
* A writable stream represents a destination for data, into which you can write.
|
|
1597
1663
|
*
|
|
@@ -1624,7 +1690,7 @@ var WritableStream = /** @class */ (function () {
|
|
|
1624
1690
|
*/
|
|
1625
1691
|
get: function () {
|
|
1626
1692
|
if (!IsWritableStream(this)) {
|
|
1627
|
-
throw streamBrandCheckException('locked');
|
|
1693
|
+
throw streamBrandCheckException$2('locked');
|
|
1628
1694
|
}
|
|
1629
1695
|
return IsWritableStreamLocked(this);
|
|
1630
1696
|
},
|
|
@@ -1643,7 +1709,7 @@ var WritableStream = /** @class */ (function () {
|
|
|
1643
1709
|
WritableStream.prototype.abort = function (reason) {
|
|
1644
1710
|
if (reason === void 0) { reason = undefined; }
|
|
1645
1711
|
if (!IsWritableStream(this)) {
|
|
1646
|
-
return promiseRejectedWith(streamBrandCheckException('abort'));
|
|
1712
|
+
return promiseRejectedWith(streamBrandCheckException$2('abort'));
|
|
1647
1713
|
}
|
|
1648
1714
|
if (IsWritableStreamLocked(this)) {
|
|
1649
1715
|
return promiseRejectedWith(new TypeError('Cannot abort a stream that already has a writer'));
|
|
@@ -1660,7 +1726,7 @@ var WritableStream = /** @class */ (function () {
|
|
|
1660
1726
|
*/
|
|
1661
1727
|
WritableStream.prototype.close = function () {
|
|
1662
1728
|
if (!IsWritableStream(this)) {
|
|
1663
|
-
return promiseRejectedWith(streamBrandCheckException('close'));
|
|
1729
|
+
return promiseRejectedWith(streamBrandCheckException$2('close'));
|
|
1664
1730
|
}
|
|
1665
1731
|
if (IsWritableStreamLocked(this)) {
|
|
1666
1732
|
return promiseRejectedWith(new TypeError('Cannot close a stream that already has a writer'));
|
|
@@ -1680,7 +1746,7 @@ var WritableStream = /** @class */ (function () {
|
|
|
1680
1746
|
*/
|
|
1681
1747
|
WritableStream.prototype.getWriter = function () {
|
|
1682
1748
|
if (!IsWritableStream(this)) {
|
|
1683
|
-
throw streamBrandCheckException('getWriter');
|
|
1749
|
+
throw streamBrandCheckException$2('getWriter');
|
|
1684
1750
|
}
|
|
1685
1751
|
return AcquireWritableStreamDefaultWriter(this);
|
|
1686
1752
|
};
|
|
@@ -1745,7 +1811,7 @@ function IsWritableStream(x) {
|
|
|
1745
1811
|
if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) {
|
|
1746
1812
|
return false;
|
|
1747
1813
|
}
|
|
1748
|
-
return
|
|
1814
|
+
return x instanceof WritableStream;
|
|
1749
1815
|
}
|
|
1750
1816
|
function IsWritableStreamLocked(stream) {
|
|
1751
1817
|
if (stream._writer === undefined) {
|
|
@@ -1754,6 +1820,15 @@ function IsWritableStreamLocked(stream) {
|
|
|
1754
1820
|
return true;
|
|
1755
1821
|
}
|
|
1756
1822
|
function WritableStreamAbort(stream, reason) {
|
|
1823
|
+
var _a;
|
|
1824
|
+
if (stream._state === 'closed' || stream._state === 'errored') {
|
|
1825
|
+
return promiseResolvedWith(undefined);
|
|
1826
|
+
}
|
|
1827
|
+
stream._writableStreamController._abortReason = reason;
|
|
1828
|
+
(_a = stream._writableStreamController._abortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
1829
|
+
// TypeScript narrows the type of `stream._state` down to 'writable' | 'erroring',
|
|
1830
|
+
// but it doesn't know that signaling abort runs author code that might have changed the state.
|
|
1831
|
+
// Widen the type again by casting to WritableStreamState.
|
|
1757
1832
|
var state = stream._state;
|
|
1758
1833
|
if (state === 'closed' || state === 'errored') {
|
|
1759
1834
|
return promiseResolvedWith(undefined);
|
|
@@ -2114,7 +2189,7 @@ function IsWritableStreamDefaultWriter(x) {
|
|
|
2114
2189
|
if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) {
|
|
2115
2190
|
return false;
|
|
2116
2191
|
}
|
|
2117
|
-
return
|
|
2192
|
+
return x instanceof WritableStreamDefaultWriter;
|
|
2118
2193
|
}
|
|
2119
2194
|
// A client of WritableStreamDefaultWriter may use these functions directly to bypass state check.
|
|
2120
2195
|
function WritableStreamDefaultWriterAbort(writer, reason) {
|
|
@@ -2204,6 +2279,38 @@ var WritableStreamDefaultController = /** @class */ (function () {
|
|
|
2204
2279
|
function WritableStreamDefaultController() {
|
|
2205
2280
|
throw new TypeError('Illegal constructor');
|
|
2206
2281
|
}
|
|
2282
|
+
Object.defineProperty(WritableStreamDefaultController.prototype, "abortReason", {
|
|
2283
|
+
/**
|
|
2284
|
+
* The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted.
|
|
2285
|
+
*/
|
|
2286
|
+
get: function () {
|
|
2287
|
+
if (!IsWritableStreamDefaultController(this)) {
|
|
2288
|
+
throw defaultControllerBrandCheckException$2('abortReason');
|
|
2289
|
+
}
|
|
2290
|
+
return this._abortReason;
|
|
2291
|
+
},
|
|
2292
|
+
enumerable: false,
|
|
2293
|
+
configurable: true
|
|
2294
|
+
});
|
|
2295
|
+
Object.defineProperty(WritableStreamDefaultController.prototype, "signal", {
|
|
2296
|
+
/**
|
|
2297
|
+
* An `AbortSignal` that can be used to abort the pending write or close operation when the stream is aborted.
|
|
2298
|
+
*/
|
|
2299
|
+
get: function () {
|
|
2300
|
+
if (!IsWritableStreamDefaultController(this)) {
|
|
2301
|
+
throw defaultControllerBrandCheckException$2('signal');
|
|
2302
|
+
}
|
|
2303
|
+
if (this._abortController === undefined) {
|
|
2304
|
+
// Older browsers or older Node versions may not support `AbortController` or `AbortSignal`.
|
|
2305
|
+
// We don't want to bundle and ship an `AbortController` polyfill together with our polyfill,
|
|
2306
|
+
// so instead we only implement support for `signal` if we find a global `AbortController` constructor.
|
|
2307
|
+
throw new TypeError('WritableStreamDefaultController.prototype.signal is not supported');
|
|
2308
|
+
}
|
|
2309
|
+
return this._abortController.signal;
|
|
2310
|
+
},
|
|
2311
|
+
enumerable: false,
|
|
2312
|
+
configurable: true
|
|
2313
|
+
});
|
|
2207
2314
|
/**
|
|
2208
2315
|
* Closes the controlled writable stream, making all future interactions with it fail with the given error `e`.
|
|
2209
2316
|
*
|
|
@@ -2214,7 +2321,7 @@ var WritableStreamDefaultController = /** @class */ (function () {
|
|
|
2214
2321
|
WritableStreamDefaultController.prototype.error = function (e) {
|
|
2215
2322
|
if (e === void 0) { e = undefined; }
|
|
2216
2323
|
if (!IsWritableStreamDefaultController(this)) {
|
|
2217
|
-
throw
|
|
2324
|
+
throw defaultControllerBrandCheckException$2('error');
|
|
2218
2325
|
}
|
|
2219
2326
|
var state = this._controlledWritableStream._state;
|
|
2220
2327
|
if (state !== 'writable') {
|
|
@@ -2253,7 +2360,7 @@ function IsWritableStreamDefaultController(x) {
|
|
|
2253
2360
|
if (!Object.prototype.hasOwnProperty.call(x, '_controlledWritableStream')) {
|
|
2254
2361
|
return false;
|
|
2255
2362
|
}
|
|
2256
|
-
return
|
|
2363
|
+
return x instanceof WritableStreamDefaultController;
|
|
2257
2364
|
}
|
|
2258
2365
|
function SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm) {
|
|
2259
2366
|
controller._controlledWritableStream = stream;
|
|
@@ -2262,6 +2369,8 @@ function SetUpWritableStreamDefaultController(stream, controller, startAlgorithm
|
|
|
2262
2369
|
controller._queue = undefined;
|
|
2263
2370
|
controller._queueTotalSize = undefined;
|
|
2264
2371
|
ResetQueue(controller);
|
|
2372
|
+
controller._abortReason = undefined;
|
|
2373
|
+
controller._abortController = createAbortController();
|
|
2265
2374
|
controller._started = false;
|
|
2266
2375
|
controller._strategySizeAlgorithm = sizeAlgorithm;
|
|
2267
2376
|
controller._strategyHWM = highWaterMark;
|
|
@@ -2411,9 +2520,13 @@ function WritableStreamDefaultControllerError(controller, error) {
|
|
|
2411
2520
|
WritableStreamStartErroring(stream, error);
|
|
2412
2521
|
}
|
|
2413
2522
|
// Helper functions for the WritableStream.
|
|
2414
|
-
function streamBrandCheckException(name) {
|
|
2523
|
+
function streamBrandCheckException$2(name) {
|
|
2415
2524
|
return new TypeError("WritableStream.prototype." + name + " can only be used on a WritableStream");
|
|
2416
2525
|
}
|
|
2526
|
+
// Helper functions for the WritableStreamDefaultController.
|
|
2527
|
+
function defaultControllerBrandCheckException$2(name) {
|
|
2528
|
+
return new TypeError("WritableStreamDefaultController.prototype." + name + " can only be used on a WritableStreamDefaultController");
|
|
2529
|
+
}
|
|
2417
2530
|
// Helper functions for the WritableStreamDefaultWriter.
|
|
2418
2531
|
function defaultWriterBrandCheckException(name) {
|
|
2419
2532
|
return new TypeError("WritableStreamDefaultWriter.prototype." + name + " can only be used on a WritableStreamDefaultWriter");
|
|
@@ -2499,19 +2612,6 @@ function defaultWriterReadyPromiseResolve(writer) {
|
|
|
2499
2612
|
writer._readyPromiseState = 'fulfilled';
|
|
2500
2613
|
}
|
|
2501
2614
|
|
|
2502
|
-
function isAbortSignal(value) {
|
|
2503
|
-
if (typeof value !== 'object' || value === null) {
|
|
2504
|
-
return false;
|
|
2505
|
-
}
|
|
2506
|
-
try {
|
|
2507
|
-
return typeof value.aborted === 'boolean';
|
|
2508
|
-
}
|
|
2509
|
-
catch (_a) {
|
|
2510
|
-
// AbortSignal.prototype.aborted throws if its brand check fails
|
|
2511
|
-
return false;
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
|
|
2515
2615
|
/// <reference lib="dom" />
|
|
2516
2616
|
var NativeDOMException = typeof DOMException !== 'undefined' ? DOMException : undefined;
|
|
2517
2617
|
|
|
@@ -2529,6 +2629,7 @@ function isDOMExceptionConstructor(ctor) {
|
|
|
2529
2629
|
}
|
|
2530
2630
|
}
|
|
2531
2631
|
function createDOMExceptionPolyfill() {
|
|
2632
|
+
// eslint-disable-next-line no-shadow
|
|
2532
2633
|
var ctor = function DOMException(message, name) {
|
|
2533
2634
|
this.message = message || '';
|
|
2534
2635
|
this.name = name || 'Error';
|
|
@@ -2540,6 +2641,7 @@ function createDOMExceptionPolyfill() {
|
|
|
2540
2641
|
Object.defineProperty(ctor.prototype, 'constructor', { value: ctor, writable: true, configurable: true });
|
|
2541
2642
|
return ctor;
|
|
2542
2643
|
}
|
|
2644
|
+
// eslint-disable-next-line no-redeclare
|
|
2543
2645
|
var DOMException$1 = isDOMExceptionConstructor(NativeDOMException) ? NativeDOMException : createDOMExceptionPolyfill();
|
|
2544
2646
|
|
|
2545
2647
|
function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
|
|
@@ -2733,7 +2835,7 @@ var ReadableStreamDefaultController = /** @class */ (function () {
|
|
|
2733
2835
|
*/
|
|
2734
2836
|
get: function () {
|
|
2735
2837
|
if (!IsReadableStreamDefaultController(this)) {
|
|
2736
|
-
throw defaultControllerBrandCheckException('desiredSize');
|
|
2838
|
+
throw defaultControllerBrandCheckException$1('desiredSize');
|
|
2737
2839
|
}
|
|
2738
2840
|
return ReadableStreamDefaultControllerGetDesiredSize(this);
|
|
2739
2841
|
},
|
|
@@ -2746,7 +2848,7 @@ var ReadableStreamDefaultController = /** @class */ (function () {
|
|
|
2746
2848
|
*/
|
|
2747
2849
|
ReadableStreamDefaultController.prototype.close = function () {
|
|
2748
2850
|
if (!IsReadableStreamDefaultController(this)) {
|
|
2749
|
-
throw defaultControllerBrandCheckException('close');
|
|
2851
|
+
throw defaultControllerBrandCheckException$1('close');
|
|
2750
2852
|
}
|
|
2751
2853
|
if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
|
|
2752
2854
|
throw new TypeError('The stream is not in a state that permits close');
|
|
@@ -2756,7 +2858,7 @@ var ReadableStreamDefaultController = /** @class */ (function () {
|
|
|
2756
2858
|
ReadableStreamDefaultController.prototype.enqueue = function (chunk) {
|
|
2757
2859
|
if (chunk === void 0) { chunk = undefined; }
|
|
2758
2860
|
if (!IsReadableStreamDefaultController(this)) {
|
|
2759
|
-
throw defaultControllerBrandCheckException('enqueue');
|
|
2861
|
+
throw defaultControllerBrandCheckException$1('enqueue');
|
|
2760
2862
|
}
|
|
2761
2863
|
if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
|
|
2762
2864
|
throw new TypeError('The stream is not in a state that permits enqueue');
|
|
@@ -2769,7 +2871,7 @@ var ReadableStreamDefaultController = /** @class */ (function () {
|
|
|
2769
2871
|
ReadableStreamDefaultController.prototype.error = function (e) {
|
|
2770
2872
|
if (e === void 0) { e = undefined; }
|
|
2771
2873
|
if (!IsReadableStreamDefaultController(this)) {
|
|
2772
|
-
throw defaultControllerBrandCheckException('error');
|
|
2874
|
+
throw defaultControllerBrandCheckException$1('error');
|
|
2773
2875
|
}
|
|
2774
2876
|
ReadableStreamDefaultControllerError(this, e);
|
|
2775
2877
|
};
|
|
@@ -2821,7 +2923,7 @@ function IsReadableStreamDefaultController(x) {
|
|
|
2821
2923
|
if (!Object.prototype.hasOwnProperty.call(x, '_controlledReadableStream')) {
|
|
2822
2924
|
return false;
|
|
2823
2925
|
}
|
|
2824
|
-
return
|
|
2926
|
+
return x instanceof ReadableStreamDefaultController;
|
|
2825
2927
|
}
|
|
2826
2928
|
function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {
|
|
2827
2929
|
var shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller);
|
|
@@ -2977,11 +3079,17 @@ function SetUpReadableStreamDefaultControllerFromUnderlyingSource(stream, underl
|
|
|
2977
3079
|
SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
|
|
2978
3080
|
}
|
|
2979
3081
|
// Helper functions for the ReadableStreamDefaultController.
|
|
2980
|
-
function defaultControllerBrandCheckException(name) {
|
|
3082
|
+
function defaultControllerBrandCheckException$1(name) {
|
|
2981
3083
|
return new TypeError("ReadableStreamDefaultController.prototype." + name + " can only be used on a ReadableStreamDefaultController");
|
|
2982
3084
|
}
|
|
2983
3085
|
|
|
2984
3086
|
function ReadableStreamTee(stream, cloneForBranch2) {
|
|
3087
|
+
if (IsReadableByteStreamController(stream._readableStreamController)) {
|
|
3088
|
+
return ReadableByteStreamTee(stream);
|
|
3089
|
+
}
|
|
3090
|
+
return ReadableStreamDefaultTee(stream);
|
|
3091
|
+
}
|
|
3092
|
+
function ReadableStreamDefaultTee(stream, cloneForBranch2) {
|
|
2985
3093
|
var reader = AcquireReadableStreamDefaultReader(stream);
|
|
2986
3094
|
var reading = false;
|
|
2987
3095
|
var canceled1 = false;
|
|
@@ -3000,26 +3108,25 @@ function ReadableStreamTee(stream, cloneForBranch2) {
|
|
|
3000
3108
|
}
|
|
3001
3109
|
reading = true;
|
|
3002
3110
|
var readRequest = {
|
|
3003
|
-
_chunkSteps: function (
|
|
3111
|
+
_chunkSteps: function (chunk) {
|
|
3004
3112
|
// This needs to be delayed a microtask because it takes at least a microtask to detect errors (using
|
|
3005
3113
|
// reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
|
|
3006
3114
|
// successful synchronously-available reads get ahead of asynchronously-available errors.
|
|
3007
3115
|
queueMicrotask(function () {
|
|
3008
3116
|
reading = false;
|
|
3009
|
-
var
|
|
3010
|
-
var
|
|
3117
|
+
var chunk1 = chunk;
|
|
3118
|
+
var chunk2 = chunk;
|
|
3011
3119
|
// There is no way to access the cloning code right now in the reference implementation.
|
|
3012
3120
|
// If we add one then we'll need an implementation for serializable objects.
|
|
3013
3121
|
// if (!canceled2 && cloneForBranch2) {
|
|
3014
|
-
//
|
|
3122
|
+
// chunk2 = StructuredDeserialize(StructuredSerialize(chunk2));
|
|
3015
3123
|
// }
|
|
3016
3124
|
if (!canceled1) {
|
|
3017
|
-
ReadableStreamDefaultControllerEnqueue(branch1._readableStreamController,
|
|
3125
|
+
ReadableStreamDefaultControllerEnqueue(branch1._readableStreamController, chunk1);
|
|
3018
3126
|
}
|
|
3019
3127
|
if (!canceled2) {
|
|
3020
|
-
ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController,
|
|
3128
|
+
ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, chunk2);
|
|
3021
3129
|
}
|
|
3022
|
-
resolveCancelPromise(undefined);
|
|
3023
3130
|
});
|
|
3024
3131
|
},
|
|
3025
3132
|
_closeSteps: function () {
|
|
@@ -3030,6 +3137,9 @@ function ReadableStreamTee(stream, cloneForBranch2) {
|
|
|
3030
3137
|
if (!canceled2) {
|
|
3031
3138
|
ReadableStreamDefaultControllerClose(branch2._readableStreamController);
|
|
3032
3139
|
}
|
|
3140
|
+
if (!canceled1 || !canceled2) {
|
|
3141
|
+
resolveCancelPromise(undefined);
|
|
3142
|
+
}
|
|
3033
3143
|
},
|
|
3034
3144
|
_errorSteps: function () {
|
|
3035
3145
|
reading = false;
|
|
@@ -3066,10 +3176,217 @@ function ReadableStreamTee(stream, cloneForBranch2) {
|
|
|
3066
3176
|
uponRejection(reader._closedPromise, function (r) {
|
|
3067
3177
|
ReadableStreamDefaultControllerError(branch1._readableStreamController, r);
|
|
3068
3178
|
ReadableStreamDefaultControllerError(branch2._readableStreamController, r);
|
|
3069
|
-
|
|
3179
|
+
if (!canceled1 || !canceled2) {
|
|
3180
|
+
resolveCancelPromise(undefined);
|
|
3181
|
+
}
|
|
3070
3182
|
});
|
|
3071
3183
|
return [branch1, branch2];
|
|
3072
3184
|
}
|
|
3185
|
+
function ReadableByteStreamTee(stream) {
|
|
3186
|
+
var reader = AcquireReadableStreamDefaultReader(stream);
|
|
3187
|
+
var reading = false;
|
|
3188
|
+
var canceled1 = false;
|
|
3189
|
+
var canceled2 = false;
|
|
3190
|
+
var reason1;
|
|
3191
|
+
var reason2;
|
|
3192
|
+
var branch1;
|
|
3193
|
+
var branch2;
|
|
3194
|
+
var resolveCancelPromise;
|
|
3195
|
+
var cancelPromise = newPromise(function (resolve) {
|
|
3196
|
+
resolveCancelPromise = resolve;
|
|
3197
|
+
});
|
|
3198
|
+
function forwardReaderError(thisReader) {
|
|
3199
|
+
uponRejection(thisReader._closedPromise, function (r) {
|
|
3200
|
+
if (thisReader !== reader) {
|
|
3201
|
+
return;
|
|
3202
|
+
}
|
|
3203
|
+
ReadableByteStreamControllerError(branch1._readableStreamController, r);
|
|
3204
|
+
ReadableByteStreamControllerError(branch2._readableStreamController, r);
|
|
3205
|
+
if (!canceled1 || !canceled2) {
|
|
3206
|
+
resolveCancelPromise(undefined);
|
|
3207
|
+
}
|
|
3208
|
+
});
|
|
3209
|
+
}
|
|
3210
|
+
function pullWithDefaultReader() {
|
|
3211
|
+
if (IsReadableStreamBYOBReader(reader)) {
|
|
3212
|
+
ReadableStreamReaderGenericRelease(reader);
|
|
3213
|
+
reader = AcquireReadableStreamDefaultReader(stream);
|
|
3214
|
+
forwardReaderError(reader);
|
|
3215
|
+
}
|
|
3216
|
+
var readRequest = {
|
|
3217
|
+
_chunkSteps: function (chunk) {
|
|
3218
|
+
// This needs to be delayed a microtask because it takes at least a microtask to detect errors (using
|
|
3219
|
+
// reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
|
|
3220
|
+
// successful synchronously-available reads get ahead of asynchronously-available errors.
|
|
3221
|
+
queueMicrotask(function () {
|
|
3222
|
+
reading = false;
|
|
3223
|
+
var chunk1 = chunk;
|
|
3224
|
+
var chunk2 = chunk;
|
|
3225
|
+
if (!canceled1 && !canceled2) {
|
|
3226
|
+
try {
|
|
3227
|
+
chunk2 = CloneAsUint8Array(chunk);
|
|
3228
|
+
}
|
|
3229
|
+
catch (cloneE) {
|
|
3230
|
+
ReadableByteStreamControllerError(branch1._readableStreamController, cloneE);
|
|
3231
|
+
ReadableByteStreamControllerError(branch2._readableStreamController, cloneE);
|
|
3232
|
+
resolveCancelPromise(ReadableStreamCancel(stream, cloneE));
|
|
3233
|
+
return;
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
if (!canceled1) {
|
|
3237
|
+
ReadableByteStreamControllerEnqueue(branch1._readableStreamController, chunk1);
|
|
3238
|
+
}
|
|
3239
|
+
if (!canceled2) {
|
|
3240
|
+
ReadableByteStreamControllerEnqueue(branch2._readableStreamController, chunk2);
|
|
3241
|
+
}
|
|
3242
|
+
});
|
|
3243
|
+
},
|
|
3244
|
+
_closeSteps: function () {
|
|
3245
|
+
reading = false;
|
|
3246
|
+
if (!canceled1) {
|
|
3247
|
+
ReadableByteStreamControllerClose(branch1._readableStreamController);
|
|
3248
|
+
}
|
|
3249
|
+
if (!canceled2) {
|
|
3250
|
+
ReadableByteStreamControllerClose(branch2._readableStreamController);
|
|
3251
|
+
}
|
|
3252
|
+
if (branch1._readableStreamController._pendingPullIntos.length > 0) {
|
|
3253
|
+
ReadableByteStreamControllerRespond(branch1._readableStreamController, 0);
|
|
3254
|
+
}
|
|
3255
|
+
if (branch2._readableStreamController._pendingPullIntos.length > 0) {
|
|
3256
|
+
ReadableByteStreamControllerRespond(branch2._readableStreamController, 0);
|
|
3257
|
+
}
|
|
3258
|
+
if (!canceled1 || !canceled2) {
|
|
3259
|
+
resolveCancelPromise(undefined);
|
|
3260
|
+
}
|
|
3261
|
+
},
|
|
3262
|
+
_errorSteps: function () {
|
|
3263
|
+
reading = false;
|
|
3264
|
+
}
|
|
3265
|
+
};
|
|
3266
|
+
ReadableStreamDefaultReaderRead(reader, readRequest);
|
|
3267
|
+
}
|
|
3268
|
+
function pullWithBYOBReader(view, forBranch2) {
|
|
3269
|
+
if (IsReadableStreamDefaultReader(reader)) {
|
|
3270
|
+
ReadableStreamReaderGenericRelease(reader);
|
|
3271
|
+
reader = AcquireReadableStreamBYOBReader(stream);
|
|
3272
|
+
forwardReaderError(reader);
|
|
3273
|
+
}
|
|
3274
|
+
var byobBranch = forBranch2 ? branch2 : branch1;
|
|
3275
|
+
var otherBranch = forBranch2 ? branch1 : branch2;
|
|
3276
|
+
var readIntoRequest = {
|
|
3277
|
+
_chunkSteps: function (chunk) {
|
|
3278
|
+
// This needs to be delayed a microtask because it takes at least a microtask to detect errors (using
|
|
3279
|
+
// reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
|
|
3280
|
+
// successful synchronously-available reads get ahead of asynchronously-available errors.
|
|
3281
|
+
queueMicrotask(function () {
|
|
3282
|
+
reading = false;
|
|
3283
|
+
var byobCanceled = forBranch2 ? canceled2 : canceled1;
|
|
3284
|
+
var otherCanceled = forBranch2 ? canceled1 : canceled2;
|
|
3285
|
+
if (!otherCanceled) {
|
|
3286
|
+
var clonedChunk = void 0;
|
|
3287
|
+
try {
|
|
3288
|
+
clonedChunk = CloneAsUint8Array(chunk);
|
|
3289
|
+
}
|
|
3290
|
+
catch (cloneE) {
|
|
3291
|
+
ReadableByteStreamControllerError(byobBranch._readableStreamController, cloneE);
|
|
3292
|
+
ReadableByteStreamControllerError(otherBranch._readableStreamController, cloneE);
|
|
3293
|
+
resolveCancelPromise(ReadableStreamCancel(stream, cloneE));
|
|
3294
|
+
return;
|
|
3295
|
+
}
|
|
3296
|
+
if (!byobCanceled) {
|
|
3297
|
+
ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk);
|
|
3298
|
+
}
|
|
3299
|
+
ReadableByteStreamControllerEnqueue(otherBranch._readableStreamController, clonedChunk);
|
|
3300
|
+
}
|
|
3301
|
+
else if (!byobCanceled) {
|
|
3302
|
+
ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk);
|
|
3303
|
+
}
|
|
3304
|
+
});
|
|
3305
|
+
},
|
|
3306
|
+
_closeSteps: function (chunk) {
|
|
3307
|
+
reading = false;
|
|
3308
|
+
var byobCanceled = forBranch2 ? canceled2 : canceled1;
|
|
3309
|
+
var otherCanceled = forBranch2 ? canceled1 : canceled2;
|
|
3310
|
+
if (!byobCanceled) {
|
|
3311
|
+
ReadableByteStreamControllerClose(byobBranch._readableStreamController);
|
|
3312
|
+
}
|
|
3313
|
+
if (!otherCanceled) {
|
|
3314
|
+
ReadableByteStreamControllerClose(otherBranch._readableStreamController);
|
|
3315
|
+
}
|
|
3316
|
+
if (chunk !== undefined) {
|
|
3317
|
+
if (!byobCanceled) {
|
|
3318
|
+
ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk);
|
|
3319
|
+
}
|
|
3320
|
+
if (!otherCanceled && otherBranch._readableStreamController._pendingPullIntos.length > 0) {
|
|
3321
|
+
ReadableByteStreamControllerRespond(otherBranch._readableStreamController, 0);
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
if (!byobCanceled || !otherCanceled) {
|
|
3325
|
+
resolveCancelPromise(undefined);
|
|
3326
|
+
}
|
|
3327
|
+
},
|
|
3328
|
+
_errorSteps: function () {
|
|
3329
|
+
reading = false;
|
|
3330
|
+
}
|
|
3331
|
+
};
|
|
3332
|
+
ReadableStreamBYOBReaderRead(reader, view, readIntoRequest);
|
|
3333
|
+
}
|
|
3334
|
+
function pull1Algorithm() {
|
|
3335
|
+
if (reading) {
|
|
3336
|
+
return promiseResolvedWith(undefined);
|
|
3337
|
+
}
|
|
3338
|
+
reading = true;
|
|
3339
|
+
var byobRequest = ReadableByteStreamControllerGetBYOBRequest(branch1._readableStreamController);
|
|
3340
|
+
if (byobRequest === null) {
|
|
3341
|
+
pullWithDefaultReader();
|
|
3342
|
+
}
|
|
3343
|
+
else {
|
|
3344
|
+
pullWithBYOBReader(byobRequest._view, false);
|
|
3345
|
+
}
|
|
3346
|
+
return promiseResolvedWith(undefined);
|
|
3347
|
+
}
|
|
3348
|
+
function pull2Algorithm() {
|
|
3349
|
+
if (reading) {
|
|
3350
|
+
return promiseResolvedWith(undefined);
|
|
3351
|
+
}
|
|
3352
|
+
reading = true;
|
|
3353
|
+
var byobRequest = ReadableByteStreamControllerGetBYOBRequest(branch2._readableStreamController);
|
|
3354
|
+
if (byobRequest === null) {
|
|
3355
|
+
pullWithDefaultReader();
|
|
3356
|
+
}
|
|
3357
|
+
else {
|
|
3358
|
+
pullWithBYOBReader(byobRequest._view, true);
|
|
3359
|
+
}
|
|
3360
|
+
return promiseResolvedWith(undefined);
|
|
3361
|
+
}
|
|
3362
|
+
function cancel1Algorithm(reason) {
|
|
3363
|
+
canceled1 = true;
|
|
3364
|
+
reason1 = reason;
|
|
3365
|
+
if (canceled2) {
|
|
3366
|
+
var compositeReason = CreateArrayFromList([reason1, reason2]);
|
|
3367
|
+
var cancelResult = ReadableStreamCancel(stream, compositeReason);
|
|
3368
|
+
resolveCancelPromise(cancelResult);
|
|
3369
|
+
}
|
|
3370
|
+
return cancelPromise;
|
|
3371
|
+
}
|
|
3372
|
+
function cancel2Algorithm(reason) {
|
|
3373
|
+
canceled2 = true;
|
|
3374
|
+
reason2 = reason;
|
|
3375
|
+
if (canceled1) {
|
|
3376
|
+
var compositeReason = CreateArrayFromList([reason1, reason2]);
|
|
3377
|
+
var cancelResult = ReadableStreamCancel(stream, compositeReason);
|
|
3378
|
+
resolveCancelPromise(cancelResult);
|
|
3379
|
+
}
|
|
3380
|
+
return cancelPromise;
|
|
3381
|
+
}
|
|
3382
|
+
function startAlgorithm() {
|
|
3383
|
+
return;
|
|
3384
|
+
}
|
|
3385
|
+
branch1 = CreateReadableByteStream(startAlgorithm, pull1Algorithm, cancel1Algorithm);
|
|
3386
|
+
branch2 = CreateReadableByteStream(startAlgorithm, pull2Algorithm, cancel2Algorithm);
|
|
3387
|
+
forwardReaderError(reader);
|
|
3388
|
+
return [branch1, branch2];
|
|
3389
|
+
}
|
|
3073
3390
|
|
|
3074
3391
|
function convertUnderlyingDefaultOrByteSource(source, context) {
|
|
3075
3392
|
assertDictionary(source, context);
|
|
@@ -3345,6 +3662,14 @@ function CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, hi
|
|
|
3345
3662
|
SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
|
|
3346
3663
|
return stream;
|
|
3347
3664
|
}
|
|
3665
|
+
// Throws if and only if startAlgorithm throws.
|
|
3666
|
+
function CreateReadableByteStream(startAlgorithm, pullAlgorithm, cancelAlgorithm) {
|
|
3667
|
+
var stream = Object.create(ReadableStream.prototype);
|
|
3668
|
+
InitializeReadableStream(stream);
|
|
3669
|
+
var controller = Object.create(ReadableByteStreamController.prototype);
|
|
3670
|
+
SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, 0, undefined);
|
|
3671
|
+
return stream;
|
|
3672
|
+
}
|
|
3348
3673
|
function InitializeReadableStream(stream) {
|
|
3349
3674
|
stream._state = 'readable';
|
|
3350
3675
|
stream._reader = undefined;
|
|
@@ -3358,7 +3683,7 @@ function IsReadableStream(x) {
|
|
|
3358
3683
|
if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) {
|
|
3359
3684
|
return false;
|
|
3360
3685
|
}
|
|
3361
|
-
return
|
|
3686
|
+
return x instanceof ReadableStream;
|
|
3362
3687
|
}
|
|
3363
3688
|
function IsReadableStreamLocked(stream) {
|
|
3364
3689
|
if (stream._reader === undefined) {
|
|
@@ -3376,6 +3701,13 @@ function ReadableStreamCancel(stream, reason) {
|
|
|
3376
3701
|
return promiseRejectedWith(stream._storedError);
|
|
3377
3702
|
}
|
|
3378
3703
|
ReadableStreamClose(stream);
|
|
3704
|
+
var reader = stream._reader;
|
|
3705
|
+
if (reader !== undefined && IsReadableStreamBYOBReader(reader)) {
|
|
3706
|
+
reader._readIntoRequests.forEach(function (readIntoRequest) {
|
|
3707
|
+
readIntoRequest._closeSteps(undefined);
|
|
3708
|
+
});
|
|
3709
|
+
reader._readIntoRequests = new SimpleQueue();
|
|
3710
|
+
}
|
|
3379
3711
|
var sourceCancelPromise = stream._readableStreamController[CancelSteps](reason);
|
|
3380
3712
|
return transformPromiseWith(sourceCancelPromise, noop);
|
|
3381
3713
|
}
|
|
@@ -3385,13 +3717,13 @@ function ReadableStreamClose(stream) {
|
|
|
3385
3717
|
if (reader === undefined) {
|
|
3386
3718
|
return;
|
|
3387
3719
|
}
|
|
3720
|
+
defaultReaderClosedPromiseResolve(reader);
|
|
3388
3721
|
if (IsReadableStreamDefaultReader(reader)) {
|
|
3389
3722
|
reader._readRequests.forEach(function (readRequest) {
|
|
3390
3723
|
readRequest._closeSteps();
|
|
3391
3724
|
});
|
|
3392
3725
|
reader._readRequests = new SimpleQueue();
|
|
3393
3726
|
}
|
|
3394
|
-
defaultReaderClosedPromiseResolve(reader);
|
|
3395
3727
|
}
|
|
3396
3728
|
function ReadableStreamError(stream, e) {
|
|
3397
3729
|
stream._state = 'errored';
|
|
@@ -3400,6 +3732,7 @@ function ReadableStreamError(stream, e) {
|
|
|
3400
3732
|
if (reader === undefined) {
|
|
3401
3733
|
return;
|
|
3402
3734
|
}
|
|
3735
|
+
defaultReaderClosedPromiseReject(reader, e);
|
|
3403
3736
|
if (IsReadableStreamDefaultReader(reader)) {
|
|
3404
3737
|
reader._readRequests.forEach(function (readRequest) {
|
|
3405
3738
|
readRequest._errorSteps(e);
|
|
@@ -3412,7 +3745,6 @@ function ReadableStreamError(stream, e) {
|
|
|
3412
3745
|
});
|
|
3413
3746
|
reader._readIntoRequests = new SimpleQueue();
|
|
3414
3747
|
}
|
|
3415
|
-
defaultReaderClosedPromiseReject(reader, e);
|
|
3416
3748
|
}
|
|
3417
3749
|
// Helper functions for the ReadableStream.
|
|
3418
3750
|
function streamBrandCheckException$1(name) {
|
|
@@ -3428,9 +3760,14 @@ function convertQueuingStrategyInit(init, context) {
|
|
|
3428
3760
|
};
|
|
3429
3761
|
}
|
|
3430
3762
|
|
|
3431
|
-
|
|
3763
|
+
// The size function must not have a prototype property nor be a constructor
|
|
3764
|
+
var byteLengthSizeFunction = function (chunk) {
|
|
3432
3765
|
return chunk.byteLength;
|
|
3433
3766
|
};
|
|
3767
|
+
Object.defineProperty(byteLengthSizeFunction, 'name', {
|
|
3768
|
+
value: 'size',
|
|
3769
|
+
configurable: true
|
|
3770
|
+
});
|
|
3434
3771
|
/**
|
|
3435
3772
|
* A queuing strategy that counts the number of bytes in each chunk.
|
|
3436
3773
|
*
|
|
@@ -3491,12 +3828,17 @@ function IsByteLengthQueuingStrategy(x) {
|
|
|
3491
3828
|
if (!Object.prototype.hasOwnProperty.call(x, '_byteLengthQueuingStrategyHighWaterMark')) {
|
|
3492
3829
|
return false;
|
|
3493
3830
|
}
|
|
3494
|
-
return
|
|
3831
|
+
return x instanceof ByteLengthQueuingStrategy;
|
|
3495
3832
|
}
|
|
3496
3833
|
|
|
3497
|
-
|
|
3834
|
+
// The size function must not have a prototype property nor be a constructor
|
|
3835
|
+
var countSizeFunction = function () {
|
|
3498
3836
|
return 1;
|
|
3499
3837
|
};
|
|
3838
|
+
Object.defineProperty(countSizeFunction, 'name', {
|
|
3839
|
+
value: 'size',
|
|
3840
|
+
configurable: true
|
|
3841
|
+
});
|
|
3500
3842
|
/**
|
|
3501
3843
|
* A queuing strategy that counts the number of chunks.
|
|
3502
3844
|
*
|
|
@@ -3558,7 +3900,7 @@ function IsCountQueuingStrategy(x) {
|
|
|
3558
3900
|
if (!Object.prototype.hasOwnProperty.call(x, '_countQueuingStrategyHighWaterMark')) {
|
|
3559
3901
|
return false;
|
|
3560
3902
|
}
|
|
3561
|
-
return
|
|
3903
|
+
return x instanceof CountQueuingStrategy;
|
|
3562
3904
|
}
|
|
3563
3905
|
|
|
3564
3906
|
function convertTransformer(original, context) {
|
|
@@ -3644,7 +3986,7 @@ var TransformStream = /** @class */ (function () {
|
|
|
3644
3986
|
*/
|
|
3645
3987
|
get: function () {
|
|
3646
3988
|
if (!IsTransformStream(this)) {
|
|
3647
|
-
throw streamBrandCheckException
|
|
3989
|
+
throw streamBrandCheckException('readable');
|
|
3648
3990
|
}
|
|
3649
3991
|
return this._readable;
|
|
3650
3992
|
},
|
|
@@ -3657,7 +3999,7 @@ var TransformStream = /** @class */ (function () {
|
|
|
3657
3999
|
*/
|
|
3658
4000
|
get: function () {
|
|
3659
4001
|
if (!IsTransformStream(this)) {
|
|
3660
|
-
throw streamBrandCheckException
|
|
4002
|
+
throw streamBrandCheckException('writable');
|
|
3661
4003
|
}
|
|
3662
4004
|
return this._writable;
|
|
3663
4005
|
},
|
|
@@ -3712,7 +4054,7 @@ function IsTransformStream(x) {
|
|
|
3712
4054
|
if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) {
|
|
3713
4055
|
return false;
|
|
3714
4056
|
}
|
|
3715
|
-
return
|
|
4057
|
+
return x instanceof TransformStream;
|
|
3716
4058
|
}
|
|
3717
4059
|
// This is a no-op if both sides are already errored.
|
|
3718
4060
|
function TransformStreamError(stream, e) {
|
|
@@ -3755,7 +4097,7 @@ var TransformStreamDefaultController = /** @class */ (function () {
|
|
|
3755
4097
|
*/
|
|
3756
4098
|
get: function () {
|
|
3757
4099
|
if (!IsTransformStreamDefaultController(this)) {
|
|
3758
|
-
throw defaultControllerBrandCheckException
|
|
4100
|
+
throw defaultControllerBrandCheckException('desiredSize');
|
|
3759
4101
|
}
|
|
3760
4102
|
var readableController = this._controlledTransformStream._readable._readableStreamController;
|
|
3761
4103
|
return ReadableStreamDefaultControllerGetDesiredSize(readableController);
|
|
@@ -3766,7 +4108,7 @@ var TransformStreamDefaultController = /** @class */ (function () {
|
|
|
3766
4108
|
TransformStreamDefaultController.prototype.enqueue = function (chunk) {
|
|
3767
4109
|
if (chunk === void 0) { chunk = undefined; }
|
|
3768
4110
|
if (!IsTransformStreamDefaultController(this)) {
|
|
3769
|
-
throw defaultControllerBrandCheckException
|
|
4111
|
+
throw defaultControllerBrandCheckException('enqueue');
|
|
3770
4112
|
}
|
|
3771
4113
|
TransformStreamDefaultControllerEnqueue(this, chunk);
|
|
3772
4114
|
};
|
|
@@ -3777,7 +4119,7 @@ var TransformStreamDefaultController = /** @class */ (function () {
|
|
|
3777
4119
|
TransformStreamDefaultController.prototype.error = function (reason) {
|
|
3778
4120
|
if (reason === void 0) { reason = undefined; }
|
|
3779
4121
|
if (!IsTransformStreamDefaultController(this)) {
|
|
3780
|
-
throw defaultControllerBrandCheckException
|
|
4122
|
+
throw defaultControllerBrandCheckException('error');
|
|
3781
4123
|
}
|
|
3782
4124
|
TransformStreamDefaultControllerError(this, reason);
|
|
3783
4125
|
};
|
|
@@ -3787,7 +4129,7 @@ var TransformStreamDefaultController = /** @class */ (function () {
|
|
|
3787
4129
|
*/
|
|
3788
4130
|
TransformStreamDefaultController.prototype.terminate = function () {
|
|
3789
4131
|
if (!IsTransformStreamDefaultController(this)) {
|
|
3790
|
-
throw defaultControllerBrandCheckException
|
|
4132
|
+
throw defaultControllerBrandCheckException('terminate');
|
|
3791
4133
|
}
|
|
3792
4134
|
TransformStreamDefaultControllerTerminate(this);
|
|
3793
4135
|
};
|
|
@@ -3813,7 +4155,7 @@ function IsTransformStreamDefaultController(x) {
|
|
|
3813
4155
|
if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) {
|
|
3814
4156
|
return false;
|
|
3815
4157
|
}
|
|
3816
|
-
return
|
|
4158
|
+
return x instanceof TransformStreamDefaultController;
|
|
3817
4159
|
}
|
|
3818
4160
|
function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm) {
|
|
3819
4161
|
controller._controlledTransformStream = stream;
|
|
@@ -3930,11 +4272,11 @@ function TransformStreamDefaultSourcePullAlgorithm(stream) {
|
|
|
3930
4272
|
return stream._backpressureChangePromise;
|
|
3931
4273
|
}
|
|
3932
4274
|
// Helper functions for the TransformStreamDefaultController.
|
|
3933
|
-
function defaultControllerBrandCheckException
|
|
4275
|
+
function defaultControllerBrandCheckException(name) {
|
|
3934
4276
|
return new TypeError("TransformStreamDefaultController.prototype." + name + " can only be used on a TransformStreamDefaultController");
|
|
3935
4277
|
}
|
|
3936
4278
|
// Helper functions for the TransformStream.
|
|
3937
|
-
function streamBrandCheckException
|
|
4279
|
+
function streamBrandCheckException(name) {
|
|
3938
4280
|
return new TypeError("TransformStream.prototype." + name + " can only be used on a TransformStream");
|
|
3939
4281
|
}
|
|
3940
4282
|
|