web-streams-polyfill 3.0.2 → 3.2.0
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 +26 -1
- package/README.md +10 -6
- package/dist/polyfill.es2018.js +491 -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 +490 -123
- package/dist/polyfill.es2018.mjs.map +1 -1
- package/dist/polyfill.es6.js +491 -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 +490 -123
- package/dist/polyfill.es6.mjs.map +1 -1
- package/dist/polyfill.js +499 -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 +498 -123
- package/dist/polyfill.mjs.map +1 -1
- package/dist/ponyfill.es2018.js +491 -124
- package/dist/ponyfill.es2018.js.map +1 -1
- package/dist/ponyfill.es2018.mjs +490 -123
- package/dist/ponyfill.es2018.mjs.map +1 -1
- package/dist/ponyfill.es6.js +491 -124
- package/dist/ponyfill.es6.js.map +1 -1
- package/dist/ponyfill.es6.mjs +490 -123
- package/dist/ponyfill.es6.mjs.map +1 -1
- package/dist/ponyfill.js +499 -124
- package/dist/ponyfill.js.map +1 -1
- package/dist/ponyfill.mjs +498 -123
- package/dist/ponyfill.mjs.map +1 -1
- package/dist/types/polyfill.d.ts +30 -10
- package/dist/types/ts3.6/polyfill.d.ts +30 -10
- package/dist/types/tsdoc-metadata.json +1 -1
- package/package.json +16 -16
package/dist/ponyfill.es6.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* web-streams-polyfill v3.0
|
|
2
|
+
* web-streams-polyfill v3.2.0
|
|
3
3
|
*/
|
|
4
4
|
/// <reference lib="es2015.symbol" />
|
|
5
5
|
const SymbolPolyfill = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ?
|
|
@@ -8,7 +8,7 @@ const SymbolPolyfill = typeof Symbol === 'function' && typeof Symbol.iterator ==
|
|
|
8
8
|
|
|
9
9
|
/// <reference lib="dom" />
|
|
10
10
|
function noop() {
|
|
11
|
-
|
|
11
|
+
return undefined;
|
|
12
12
|
}
|
|
13
13
|
function getGlobals() {
|
|
14
14
|
if (typeof self !== 'undefined') {
|
|
@@ -27,7 +27,7 @@ const globals = getGlobals();
|
|
|
27
27
|
function typeIsObject(x) {
|
|
28
28
|
return (typeof x === 'object' && x !== null) || typeof x === 'function';
|
|
29
29
|
}
|
|
30
|
-
const rethrowAssertionErrorRejection =
|
|
30
|
+
const rethrowAssertionErrorRejection = noop;
|
|
31
31
|
|
|
32
32
|
const originalPromise = Promise;
|
|
33
33
|
const originalPromiseThen = Promise.prototype.then;
|
|
@@ -488,7 +488,7 @@ function IsReadableStreamDefaultReader(x) {
|
|
|
488
488
|
if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {
|
|
489
489
|
return false;
|
|
490
490
|
}
|
|
491
|
-
return
|
|
491
|
+
return x instanceof ReadableStreamDefaultReader;
|
|
492
492
|
}
|
|
493
493
|
function ReadableStreamDefaultReaderRead(reader, readRequest) {
|
|
494
494
|
const stream = reader._ownerReadableStream;
|
|
@@ -631,7 +631,14 @@ function IsReadableStreamAsyncIterator(x) {
|
|
|
631
631
|
if (!Object.prototype.hasOwnProperty.call(x, '_asyncIteratorImpl')) {
|
|
632
632
|
return false;
|
|
633
633
|
}
|
|
634
|
-
|
|
634
|
+
try {
|
|
635
|
+
// noinspection SuspiciousTypeOfGuard
|
|
636
|
+
return x._asyncIteratorImpl instanceof
|
|
637
|
+
ReadableStreamAsyncIteratorImpl;
|
|
638
|
+
}
|
|
639
|
+
catch (_a) {
|
|
640
|
+
return false;
|
|
641
|
+
}
|
|
635
642
|
}
|
|
636
643
|
// Helper functions for the ReadableStream.
|
|
637
644
|
function streamAsyncIteratorBrandCheckException(name) {
|
|
@@ -645,15 +652,35 @@ const NumberIsNaN = Number.isNaN || function (x) {
|
|
|
645
652
|
return x !== x;
|
|
646
653
|
};
|
|
647
654
|
|
|
648
|
-
function
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
655
|
+
function CreateArrayFromList(elements) {
|
|
656
|
+
// We use arrays to represent lists, so this is basically a no-op.
|
|
657
|
+
// Do a slice though just in case we happen to depend on the unique-ness.
|
|
658
|
+
return elements.slice();
|
|
659
|
+
}
|
|
660
|
+
function CopyDataBlockBytes(dest, destOffset, src, srcOffset, n) {
|
|
661
|
+
new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
|
|
662
|
+
}
|
|
663
|
+
// Not implemented correctly
|
|
664
|
+
function TransferArrayBuffer(O) {
|
|
665
|
+
return O;
|
|
666
|
+
}
|
|
667
|
+
// Not implemented correctly
|
|
668
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
669
|
+
function IsDetachedBuffer(O) {
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
672
|
+
function ArrayBufferSlice(buffer, begin, end) {
|
|
673
|
+
// ArrayBuffer.prototype.slice is not available on IE10
|
|
674
|
+
// https://www.caniuse.com/mdn-javascript_builtins_arraybuffer_slice
|
|
675
|
+
if (buffer.slice) {
|
|
676
|
+
return buffer.slice(begin, end);
|
|
654
677
|
}
|
|
655
|
-
|
|
678
|
+
const length = end - begin;
|
|
679
|
+
const slice = new ArrayBuffer(length);
|
|
680
|
+
CopyDataBlockBytes(slice, 0, buffer, begin, length);
|
|
681
|
+
return slice;
|
|
656
682
|
}
|
|
683
|
+
|
|
657
684
|
function IsNonNegativeNumber(v) {
|
|
658
685
|
if (typeof v !== 'number') {
|
|
659
686
|
return false;
|
|
@@ -666,6 +693,10 @@ function IsNonNegativeNumber(v) {
|
|
|
666
693
|
}
|
|
667
694
|
return true;
|
|
668
695
|
}
|
|
696
|
+
function CloneAsUint8Array(O) {
|
|
697
|
+
const buffer = ArrayBufferSlice(O.buffer, O.byteOffset, O.byteOffset + O.byteLength);
|
|
698
|
+
return new Uint8Array(buffer);
|
|
699
|
+
}
|
|
669
700
|
|
|
670
701
|
function DequeueValue(container) {
|
|
671
702
|
const pair = container._queue.shift();
|
|
@@ -676,8 +707,7 @@ function DequeueValue(container) {
|
|
|
676
707
|
return pair.value;
|
|
677
708
|
}
|
|
678
709
|
function EnqueueValueWithSize(container, value, size) {
|
|
679
|
-
size
|
|
680
|
-
if (!IsFiniteNonNegativeNumber(size)) {
|
|
710
|
+
if (!IsNonNegativeNumber(size) || size === Infinity) {
|
|
681
711
|
throw new RangeError('Size must be a finite, non-NaN, non-negative number.');
|
|
682
712
|
}
|
|
683
713
|
container._queue.push({ value, size });
|
|
@@ -692,23 +722,6 @@ function ResetQueue(container) {
|
|
|
692
722
|
container._queueTotalSize = 0;
|
|
693
723
|
}
|
|
694
724
|
|
|
695
|
-
function CreateArrayFromList(elements) {
|
|
696
|
-
// We use arrays to represent lists, so this is basically a no-op.
|
|
697
|
-
// Do a slice though just in case we happen to depend on the unique-ness.
|
|
698
|
-
return elements.slice();
|
|
699
|
-
}
|
|
700
|
-
function CopyDataBlockBytes(dest, destOffset, src, srcOffset, n) {
|
|
701
|
-
new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
|
|
702
|
-
}
|
|
703
|
-
// Not implemented correctly
|
|
704
|
-
function TransferArrayBuffer(O) {
|
|
705
|
-
return O;
|
|
706
|
-
}
|
|
707
|
-
// Not implemented correctly
|
|
708
|
-
function IsDetachedBuffer(O) {
|
|
709
|
-
return false;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
725
|
/**
|
|
713
726
|
* A pull-into request in a {@link ReadableByteStreamController}.
|
|
714
727
|
*
|
|
@@ -747,15 +760,10 @@ class ReadableStreamBYOBRequest {
|
|
|
747
760
|
if (!ArrayBuffer.isView(view)) {
|
|
748
761
|
throw new TypeError('You can only respond with array buffer views');
|
|
749
762
|
}
|
|
750
|
-
if (view.byteLength === 0) {
|
|
751
|
-
throw new TypeError('chunk must have non-zero byteLength');
|
|
752
|
-
}
|
|
753
|
-
if (view.buffer.byteLength === 0) {
|
|
754
|
-
throw new TypeError(`chunk's buffer must have non-zero byteLength`);
|
|
755
|
-
}
|
|
756
763
|
if (this._associatedReadableByteStreamController === undefined) {
|
|
757
764
|
throw new TypeError('This BYOB request has been invalidated');
|
|
758
765
|
}
|
|
766
|
+
if (IsDetachedBuffer(view.buffer)) ;
|
|
759
767
|
ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
|
|
760
768
|
}
|
|
761
769
|
}
|
|
@@ -786,14 +794,7 @@ class ReadableByteStreamController {
|
|
|
786
794
|
if (!IsReadableByteStreamController(this)) {
|
|
787
795
|
throw byteStreamControllerBrandCheckException('byobRequest');
|
|
788
796
|
}
|
|
789
|
-
|
|
790
|
-
const firstDescriptor = this._pendingPullIntos.peek();
|
|
791
|
-
const view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
|
|
792
|
-
const byobRequest = Object.create(ReadableStreamBYOBRequest.prototype);
|
|
793
|
-
SetUpReadableStreamBYOBRequest(byobRequest, this, view);
|
|
794
|
-
this._byobRequest = byobRequest;
|
|
795
|
-
}
|
|
796
|
-
return this._byobRequest;
|
|
797
|
+
return ReadableByteStreamControllerGetBYOBRequest(this);
|
|
797
798
|
}
|
|
798
799
|
/**
|
|
799
800
|
* Returns the desired size to fill the controlled stream's internal queue. It can be negative, if the queue is
|
|
@@ -856,10 +857,7 @@ class ReadableByteStreamController {
|
|
|
856
857
|
}
|
|
857
858
|
/** @internal */
|
|
858
859
|
[CancelSteps](reason) {
|
|
859
|
-
|
|
860
|
-
const firstDescriptor = this._pendingPullIntos.peek();
|
|
861
|
-
firstDescriptor.bytesFilled = 0;
|
|
862
|
-
}
|
|
860
|
+
ReadableByteStreamControllerClearPendingPullIntos(this);
|
|
863
861
|
ResetQueue(this);
|
|
864
862
|
const result = this._cancelAlgorithm(reason);
|
|
865
863
|
ReadableByteStreamControllerClearAlgorithms(this);
|
|
@@ -888,6 +886,7 @@ class ReadableByteStreamController {
|
|
|
888
886
|
}
|
|
889
887
|
const pullIntoDescriptor = {
|
|
890
888
|
buffer,
|
|
889
|
+
bufferByteLength: autoAllocateChunkSize,
|
|
891
890
|
byteOffset: 0,
|
|
892
891
|
byteLength: autoAllocateChunkSize,
|
|
893
892
|
bytesFilled: 0,
|
|
@@ -922,7 +921,7 @@ function IsReadableByteStreamController(x) {
|
|
|
922
921
|
if (!Object.prototype.hasOwnProperty.call(x, '_controlledReadableByteStream')) {
|
|
923
922
|
return false;
|
|
924
923
|
}
|
|
925
|
-
return
|
|
924
|
+
return x instanceof ReadableByteStreamController;
|
|
926
925
|
}
|
|
927
926
|
function IsReadableStreamBYOBRequest(x) {
|
|
928
927
|
if (!typeIsObject(x)) {
|
|
@@ -931,7 +930,7 @@ function IsReadableStreamBYOBRequest(x) {
|
|
|
931
930
|
if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) {
|
|
932
931
|
return false;
|
|
933
932
|
}
|
|
934
|
-
return
|
|
933
|
+
return x instanceof ReadableStreamBYOBRequest;
|
|
935
934
|
}
|
|
936
935
|
function ReadableByteStreamControllerCallPullIfNeeded(controller) {
|
|
937
936
|
const shouldPull = ReadableByteStreamControllerShouldCallPull(controller);
|
|
@@ -1013,7 +1012,6 @@ function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller,
|
|
|
1013
1012
|
return ready;
|
|
1014
1013
|
}
|
|
1015
1014
|
function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {
|
|
1016
|
-
ReadableByteStreamControllerInvalidateBYOBRequest(controller);
|
|
1017
1015
|
pullIntoDescriptor.bytesFilled += size;
|
|
1018
1016
|
}
|
|
1019
1017
|
function ReadableByteStreamControllerHandleQueueDrain(controller) {
|
|
@@ -1052,9 +1050,15 @@ function ReadableByteStreamControllerPullInto(controller, view, readIntoRequest)
|
|
|
1052
1050
|
elementSize = view.constructor.BYTES_PER_ELEMENT;
|
|
1053
1051
|
}
|
|
1054
1052
|
const ctor = view.constructor;
|
|
1053
|
+
// try {
|
|
1055
1054
|
const buffer = TransferArrayBuffer(view.buffer);
|
|
1055
|
+
// } catch (e) {
|
|
1056
|
+
// readIntoRequest._errorSteps(e);
|
|
1057
|
+
// return;
|
|
1058
|
+
// }
|
|
1056
1059
|
const pullIntoDescriptor = {
|
|
1057
1060
|
buffer,
|
|
1061
|
+
bufferByteLength: buffer.byteLength,
|
|
1058
1062
|
byteOffset: view.byteOffset,
|
|
1059
1063
|
byteLength: view.byteLength,
|
|
1060
1064
|
bytesFilled: 0,
|
|
@@ -1094,7 +1098,6 @@ function ReadableByteStreamControllerPullInto(controller, view, readIntoRequest)
|
|
|
1094
1098
|
ReadableByteStreamControllerCallPullIfNeeded(controller);
|
|
1095
1099
|
}
|
|
1096
1100
|
function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
|
|
1097
|
-
firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
|
|
1098
1101
|
const stream = controller._controlledReadableByteStream;
|
|
1099
1102
|
if (ReadableStreamHasBYOBReader(stream)) {
|
|
1100
1103
|
while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
|
|
@@ -1104,34 +1107,27 @@ function ReadableByteStreamControllerRespondInClosedState(controller, firstDescr
|
|
|
1104
1107
|
}
|
|
1105
1108
|
}
|
|
1106
1109
|
function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
|
|
1107
|
-
if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) {
|
|
1108
|
-
throw new RangeError('bytesWritten out of range');
|
|
1109
|
-
}
|
|
1110
1110
|
ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
|
|
1111
1111
|
if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
|
|
1112
|
-
// TODO: Figure out whether we should detach the buffer or not here.
|
|
1113
1112
|
return;
|
|
1114
1113
|
}
|
|
1115
1114
|
ReadableByteStreamControllerShiftPendingPullInto(controller);
|
|
1116
1115
|
const remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
|
|
1117
1116
|
if (remainderSize > 0) {
|
|
1118
1117
|
const end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
|
|
1119
|
-
const remainder = pullIntoDescriptor.buffer
|
|
1118
|
+
const remainder = ArrayBufferSlice(pullIntoDescriptor.buffer, end - remainderSize, end);
|
|
1120
1119
|
ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
|
|
1121
1120
|
}
|
|
1122
|
-
pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
|
|
1123
1121
|
pullIntoDescriptor.bytesFilled -= remainderSize;
|
|
1124
1122
|
ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor);
|
|
1125
1123
|
ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
|
|
1126
1124
|
}
|
|
1127
1125
|
function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
|
|
1128
1126
|
const firstDescriptor = controller._pendingPullIntos.peek();
|
|
1127
|
+
ReadableByteStreamControllerInvalidateBYOBRequest(controller);
|
|
1129
1128
|
const state = controller._controlledReadableByteStream._state;
|
|
1130
1129
|
if (state === 'closed') {
|
|
1131
|
-
|
|
1132
|
-
throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
|
|
1133
|
-
}
|
|
1134
|
-
ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
|
|
1130
|
+
ReadableByteStreamControllerRespondInClosedState(controller);
|
|
1135
1131
|
}
|
|
1136
1132
|
else {
|
|
1137
1133
|
ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
|
|
@@ -1140,7 +1136,6 @@ function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
|
|
|
1140
1136
|
}
|
|
1141
1137
|
function ReadableByteStreamControllerShiftPendingPullInto(controller) {
|
|
1142
1138
|
const descriptor = controller._pendingPullIntos.shift();
|
|
1143
|
-
ReadableByteStreamControllerInvalidateBYOBRequest(controller);
|
|
1144
1139
|
return descriptor;
|
|
1145
1140
|
}
|
|
1146
1141
|
function ReadableByteStreamControllerShouldCallPull(controller) {
|
|
@@ -1200,11 +1195,20 @@ function ReadableByteStreamControllerEnqueue(controller, chunk) {
|
|
|
1200
1195
|
const byteOffset = chunk.byteOffset;
|
|
1201
1196
|
const byteLength = chunk.byteLength;
|
|
1202
1197
|
const transferredBuffer = TransferArrayBuffer(buffer);
|
|
1198
|
+
if (controller._pendingPullIntos.length > 0) {
|
|
1199
|
+
const firstPendingPullInto = controller._pendingPullIntos.peek();
|
|
1200
|
+
if (IsDetachedBuffer(firstPendingPullInto.buffer)) ;
|
|
1201
|
+
firstPendingPullInto.buffer = TransferArrayBuffer(firstPendingPullInto.buffer);
|
|
1202
|
+
}
|
|
1203
|
+
ReadableByteStreamControllerInvalidateBYOBRequest(controller);
|
|
1203
1204
|
if (ReadableStreamHasDefaultReader(stream)) {
|
|
1204
1205
|
if (ReadableStreamGetNumReadRequests(stream) === 0) {
|
|
1205
1206
|
ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
|
|
1206
1207
|
}
|
|
1207
1208
|
else {
|
|
1209
|
+
if (controller._pendingPullIntos.length > 0) {
|
|
1210
|
+
ReadableByteStreamControllerShiftPendingPullInto(controller);
|
|
1211
|
+
}
|
|
1208
1212
|
const transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
|
|
1209
1213
|
ReadableStreamFulfillReadRequest(stream, transferredView, false);
|
|
1210
1214
|
}
|
|
@@ -1229,6 +1233,16 @@ function ReadableByteStreamControllerError(controller, e) {
|
|
|
1229
1233
|
ReadableByteStreamControllerClearAlgorithms(controller);
|
|
1230
1234
|
ReadableStreamError(stream, e);
|
|
1231
1235
|
}
|
|
1236
|
+
function ReadableByteStreamControllerGetBYOBRequest(controller) {
|
|
1237
|
+
if (controller._byobRequest === null && controller._pendingPullIntos.length > 0) {
|
|
1238
|
+
const firstDescriptor = controller._pendingPullIntos.peek();
|
|
1239
|
+
const view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
|
|
1240
|
+
const byobRequest = Object.create(ReadableStreamBYOBRequest.prototype);
|
|
1241
|
+
SetUpReadableStreamBYOBRequest(byobRequest, controller, view);
|
|
1242
|
+
controller._byobRequest = byobRequest;
|
|
1243
|
+
}
|
|
1244
|
+
return controller._byobRequest;
|
|
1245
|
+
}
|
|
1232
1246
|
function ReadableByteStreamControllerGetDesiredSize(controller) {
|
|
1233
1247
|
const state = controller._controlledReadableByteStream._state;
|
|
1234
1248
|
if (state === 'errored') {
|
|
@@ -1240,22 +1254,49 @@ function ReadableByteStreamControllerGetDesiredSize(controller) {
|
|
|
1240
1254
|
return controller._strategyHWM - controller._queueTotalSize;
|
|
1241
1255
|
}
|
|
1242
1256
|
function ReadableByteStreamControllerRespond(controller, bytesWritten) {
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1257
|
+
const firstDescriptor = controller._pendingPullIntos.peek();
|
|
1258
|
+
const state = controller._controlledReadableByteStream._state;
|
|
1259
|
+
if (state === 'closed') {
|
|
1260
|
+
if (bytesWritten !== 0) {
|
|
1261
|
+
throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
else {
|
|
1265
|
+
if (bytesWritten === 0) {
|
|
1266
|
+
throw new TypeError('bytesWritten must be greater than 0 when calling respond() on a readable stream');
|
|
1267
|
+
}
|
|
1268
|
+
if (firstDescriptor.bytesFilled + bytesWritten > firstDescriptor.byteLength) {
|
|
1269
|
+
throw new RangeError('bytesWritten out of range');
|
|
1270
|
+
}
|
|
1246
1271
|
}
|
|
1272
|
+
firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
|
|
1247
1273
|
ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
|
|
1248
1274
|
}
|
|
1249
1275
|
function ReadableByteStreamControllerRespondWithNewView(controller, view) {
|
|
1250
1276
|
const firstDescriptor = controller._pendingPullIntos.peek();
|
|
1277
|
+
const state = controller._controlledReadableByteStream._state;
|
|
1278
|
+
if (state === 'closed') {
|
|
1279
|
+
if (view.byteLength !== 0) {
|
|
1280
|
+
throw new TypeError('The view\'s length must be 0 when calling respondWithNewView() on a closed stream');
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
else {
|
|
1284
|
+
if (view.byteLength === 0) {
|
|
1285
|
+
throw new TypeError('The view\'s length must be greater than 0 when calling respondWithNewView() on a readable stream');
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1251
1288
|
if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {
|
|
1252
1289
|
throw new RangeError('The region specified by view does not match byobRequest');
|
|
1253
1290
|
}
|
|
1254
|
-
if (firstDescriptor.
|
|
1291
|
+
if (firstDescriptor.bufferByteLength !== view.buffer.byteLength) {
|
|
1255
1292
|
throw new RangeError('The buffer of view has different capacity than byobRequest');
|
|
1256
1293
|
}
|
|
1257
|
-
firstDescriptor.
|
|
1258
|
-
|
|
1294
|
+
if (firstDescriptor.bytesFilled + view.byteLength > firstDescriptor.byteLength) {
|
|
1295
|
+
throw new RangeError('The region specified by view is larger than byobRequest');
|
|
1296
|
+
}
|
|
1297
|
+
const viewByteLength = view.byteLength;
|
|
1298
|
+
firstDescriptor.buffer = TransferArrayBuffer(view.buffer);
|
|
1299
|
+
ReadableByteStreamControllerRespondInternal(controller, viewByteLength);
|
|
1259
1300
|
}
|
|
1260
1301
|
function SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize) {
|
|
1261
1302
|
controller._controlledReadableByteStream = stream;
|
|
@@ -1404,6 +1445,7 @@ class ReadableStreamBYOBReader {
|
|
|
1404
1445
|
if (view.buffer.byteLength === 0) {
|
|
1405
1446
|
return promiseRejectedWith(new TypeError(`view's buffer must have non-zero byteLength`));
|
|
1406
1447
|
}
|
|
1448
|
+
if (IsDetachedBuffer(view.buffer)) ;
|
|
1407
1449
|
if (this._ownerReadableStream === undefined) {
|
|
1408
1450
|
return promiseRejectedWith(readerLockException('read from'));
|
|
1409
1451
|
}
|
|
@@ -1463,7 +1505,7 @@ function IsReadableStreamBYOBReader(x) {
|
|
|
1463
1505
|
if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) {
|
|
1464
1506
|
return false;
|
|
1465
1507
|
}
|
|
1466
|
-
return
|
|
1508
|
+
return x instanceof ReadableStreamBYOBReader;
|
|
1467
1509
|
}
|
|
1468
1510
|
function ReadableStreamBYOBReaderRead(reader, view, readIntoRequest) {
|
|
1469
1511
|
const stream = reader._ownerReadableStream;
|
|
@@ -1558,6 +1600,31 @@ function assertWritableStream(x, context) {
|
|
|
1558
1600
|
}
|
|
1559
1601
|
}
|
|
1560
1602
|
|
|
1603
|
+
function isAbortSignal(value) {
|
|
1604
|
+
if (typeof value !== 'object' || value === null) {
|
|
1605
|
+
return false;
|
|
1606
|
+
}
|
|
1607
|
+
try {
|
|
1608
|
+
return typeof value.aborted === 'boolean';
|
|
1609
|
+
}
|
|
1610
|
+
catch (_a) {
|
|
1611
|
+
// AbortSignal.prototype.aborted throws if its brand check fails
|
|
1612
|
+
return false;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
const supportsAbortController = typeof AbortController === 'function';
|
|
1616
|
+
/**
|
|
1617
|
+
* Construct a new AbortController, if supported by the platform.
|
|
1618
|
+
*
|
|
1619
|
+
* @internal
|
|
1620
|
+
*/
|
|
1621
|
+
function createAbortController() {
|
|
1622
|
+
if (supportsAbortController) {
|
|
1623
|
+
return new AbortController();
|
|
1624
|
+
}
|
|
1625
|
+
return undefined;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1561
1628
|
/**
|
|
1562
1629
|
* A writable stream represents a destination for data, into which you can write.
|
|
1563
1630
|
*
|
|
@@ -1587,7 +1654,7 @@ class WritableStream {
|
|
|
1587
1654
|
*/
|
|
1588
1655
|
get locked() {
|
|
1589
1656
|
if (!IsWritableStream(this)) {
|
|
1590
|
-
throw streamBrandCheckException('locked');
|
|
1657
|
+
throw streamBrandCheckException$2('locked');
|
|
1591
1658
|
}
|
|
1592
1659
|
return IsWritableStreamLocked(this);
|
|
1593
1660
|
}
|
|
@@ -1602,7 +1669,7 @@ class WritableStream {
|
|
|
1602
1669
|
*/
|
|
1603
1670
|
abort(reason = undefined) {
|
|
1604
1671
|
if (!IsWritableStream(this)) {
|
|
1605
|
-
return promiseRejectedWith(streamBrandCheckException('abort'));
|
|
1672
|
+
return promiseRejectedWith(streamBrandCheckException$2('abort'));
|
|
1606
1673
|
}
|
|
1607
1674
|
if (IsWritableStreamLocked(this)) {
|
|
1608
1675
|
return promiseRejectedWith(new TypeError('Cannot abort a stream that already has a writer'));
|
|
@@ -1619,7 +1686,7 @@ class WritableStream {
|
|
|
1619
1686
|
*/
|
|
1620
1687
|
close() {
|
|
1621
1688
|
if (!IsWritableStream(this)) {
|
|
1622
|
-
return promiseRejectedWith(streamBrandCheckException('close'));
|
|
1689
|
+
return promiseRejectedWith(streamBrandCheckException$2('close'));
|
|
1623
1690
|
}
|
|
1624
1691
|
if (IsWritableStreamLocked(this)) {
|
|
1625
1692
|
return promiseRejectedWith(new TypeError('Cannot close a stream that already has a writer'));
|
|
@@ -1639,7 +1706,7 @@ class WritableStream {
|
|
|
1639
1706
|
*/
|
|
1640
1707
|
getWriter() {
|
|
1641
1708
|
if (!IsWritableStream(this)) {
|
|
1642
|
-
throw streamBrandCheckException('getWriter');
|
|
1709
|
+
throw streamBrandCheckException$2('getWriter');
|
|
1643
1710
|
}
|
|
1644
1711
|
return AcquireWritableStreamDefaultWriter(this);
|
|
1645
1712
|
}
|
|
@@ -1701,7 +1768,7 @@ function IsWritableStream(x) {
|
|
|
1701
1768
|
if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) {
|
|
1702
1769
|
return false;
|
|
1703
1770
|
}
|
|
1704
|
-
return
|
|
1771
|
+
return x instanceof WritableStream;
|
|
1705
1772
|
}
|
|
1706
1773
|
function IsWritableStreamLocked(stream) {
|
|
1707
1774
|
if (stream._writer === undefined) {
|
|
@@ -1710,6 +1777,15 @@ function IsWritableStreamLocked(stream) {
|
|
|
1710
1777
|
return true;
|
|
1711
1778
|
}
|
|
1712
1779
|
function WritableStreamAbort(stream, reason) {
|
|
1780
|
+
var _a;
|
|
1781
|
+
if (stream._state === 'closed' || stream._state === 'errored') {
|
|
1782
|
+
return promiseResolvedWith(undefined);
|
|
1783
|
+
}
|
|
1784
|
+
stream._writableStreamController._abortReason = reason;
|
|
1785
|
+
(_a = stream._writableStreamController._abortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
1786
|
+
// TypeScript narrows the type of `stream._state` down to 'writable' | 'erroring',
|
|
1787
|
+
// but it doesn't know that signaling abort runs author code that might have changed the state.
|
|
1788
|
+
// Widen the type again by casting to WritableStreamState.
|
|
1713
1789
|
const state = stream._state;
|
|
1714
1790
|
if (state === 'closed' || state === 'errored') {
|
|
1715
1791
|
return promiseResolvedWith(undefined);
|
|
@@ -2055,7 +2131,7 @@ function IsWritableStreamDefaultWriter(x) {
|
|
|
2055
2131
|
if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) {
|
|
2056
2132
|
return false;
|
|
2057
2133
|
}
|
|
2058
|
-
return
|
|
2134
|
+
return x instanceof WritableStreamDefaultWriter;
|
|
2059
2135
|
}
|
|
2060
2136
|
// A client of WritableStreamDefaultWriter may use these functions directly to bypass state check.
|
|
2061
2137
|
function WritableStreamDefaultWriterAbort(writer, reason) {
|
|
@@ -2145,6 +2221,34 @@ class WritableStreamDefaultController {
|
|
|
2145
2221
|
constructor() {
|
|
2146
2222
|
throw new TypeError('Illegal constructor');
|
|
2147
2223
|
}
|
|
2224
|
+
/**
|
|
2225
|
+
* The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted.
|
|
2226
|
+
*
|
|
2227
|
+
* @deprecated
|
|
2228
|
+
* This property has been removed from the specification, see https://github.com/whatwg/streams/pull/1177.
|
|
2229
|
+
* Use {@link WritableStreamDefaultController.signal}'s `reason` instead.
|
|
2230
|
+
*/
|
|
2231
|
+
get abortReason() {
|
|
2232
|
+
if (!IsWritableStreamDefaultController(this)) {
|
|
2233
|
+
throw defaultControllerBrandCheckException$2('abortReason');
|
|
2234
|
+
}
|
|
2235
|
+
return this._abortReason;
|
|
2236
|
+
}
|
|
2237
|
+
/**
|
|
2238
|
+
* An `AbortSignal` that can be used to abort the pending write or close operation when the stream is aborted.
|
|
2239
|
+
*/
|
|
2240
|
+
get signal() {
|
|
2241
|
+
if (!IsWritableStreamDefaultController(this)) {
|
|
2242
|
+
throw defaultControllerBrandCheckException$2('signal');
|
|
2243
|
+
}
|
|
2244
|
+
if (this._abortController === undefined) {
|
|
2245
|
+
// Older browsers or older Node versions may not support `AbortController` or `AbortSignal`.
|
|
2246
|
+
// We don't want to bundle and ship an `AbortController` polyfill together with our polyfill,
|
|
2247
|
+
// so instead we only implement support for `signal` if we find a global `AbortController` constructor.
|
|
2248
|
+
throw new TypeError('WritableStreamDefaultController.prototype.signal is not supported');
|
|
2249
|
+
}
|
|
2250
|
+
return this._abortController.signal;
|
|
2251
|
+
}
|
|
2148
2252
|
/**
|
|
2149
2253
|
* Closes the controlled writable stream, making all future interactions with it fail with the given error `e`.
|
|
2150
2254
|
*
|
|
@@ -2154,7 +2258,7 @@ class WritableStreamDefaultController {
|
|
|
2154
2258
|
*/
|
|
2155
2259
|
error(e = undefined) {
|
|
2156
2260
|
if (!IsWritableStreamDefaultController(this)) {
|
|
2157
|
-
throw
|
|
2261
|
+
throw defaultControllerBrandCheckException$2('error');
|
|
2158
2262
|
}
|
|
2159
2263
|
const state = this._controlledWritableStream._state;
|
|
2160
2264
|
if (state !== 'writable') {
|
|
@@ -2176,6 +2280,8 @@ class WritableStreamDefaultController {
|
|
|
2176
2280
|
}
|
|
2177
2281
|
}
|
|
2178
2282
|
Object.defineProperties(WritableStreamDefaultController.prototype, {
|
|
2283
|
+
abortReason: { enumerable: true },
|
|
2284
|
+
signal: { enumerable: true },
|
|
2179
2285
|
error: { enumerable: true }
|
|
2180
2286
|
});
|
|
2181
2287
|
if (typeof SymbolPolyfill.toStringTag === 'symbol') {
|
|
@@ -2192,7 +2298,7 @@ function IsWritableStreamDefaultController(x) {
|
|
|
2192
2298
|
if (!Object.prototype.hasOwnProperty.call(x, '_controlledWritableStream')) {
|
|
2193
2299
|
return false;
|
|
2194
2300
|
}
|
|
2195
|
-
return
|
|
2301
|
+
return x instanceof WritableStreamDefaultController;
|
|
2196
2302
|
}
|
|
2197
2303
|
function SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm) {
|
|
2198
2304
|
controller._controlledWritableStream = stream;
|
|
@@ -2201,6 +2307,8 @@ function SetUpWritableStreamDefaultController(stream, controller, startAlgorithm
|
|
|
2201
2307
|
controller._queue = undefined;
|
|
2202
2308
|
controller._queueTotalSize = undefined;
|
|
2203
2309
|
ResetQueue(controller);
|
|
2310
|
+
controller._abortReason = undefined;
|
|
2311
|
+
controller._abortController = createAbortController();
|
|
2204
2312
|
controller._started = false;
|
|
2205
2313
|
controller._strategySizeAlgorithm = sizeAlgorithm;
|
|
2206
2314
|
controller._strategyHWM = highWaterMark;
|
|
@@ -2350,9 +2458,13 @@ function WritableStreamDefaultControllerError(controller, error) {
|
|
|
2350
2458
|
WritableStreamStartErroring(stream, error);
|
|
2351
2459
|
}
|
|
2352
2460
|
// Helper functions for the WritableStream.
|
|
2353
|
-
function streamBrandCheckException(name) {
|
|
2461
|
+
function streamBrandCheckException$2(name) {
|
|
2354
2462
|
return new TypeError(`WritableStream.prototype.${name} can only be used on a WritableStream`);
|
|
2355
2463
|
}
|
|
2464
|
+
// Helper functions for the WritableStreamDefaultController.
|
|
2465
|
+
function defaultControllerBrandCheckException$2(name) {
|
|
2466
|
+
return new TypeError(`WritableStreamDefaultController.prototype.${name} can only be used on a WritableStreamDefaultController`);
|
|
2467
|
+
}
|
|
2356
2468
|
// Helper functions for the WritableStreamDefaultWriter.
|
|
2357
2469
|
function defaultWriterBrandCheckException(name) {
|
|
2358
2470
|
return new TypeError(`WritableStreamDefaultWriter.prototype.${name} can only be used on a WritableStreamDefaultWriter`);
|
|
@@ -2438,19 +2550,6 @@ function defaultWriterReadyPromiseResolve(writer) {
|
|
|
2438
2550
|
writer._readyPromiseState = 'fulfilled';
|
|
2439
2551
|
}
|
|
2440
2552
|
|
|
2441
|
-
function isAbortSignal(value) {
|
|
2442
|
-
if (typeof value !== 'object' || value === null) {
|
|
2443
|
-
return false;
|
|
2444
|
-
}
|
|
2445
|
-
try {
|
|
2446
|
-
return typeof value.aborted === 'boolean';
|
|
2447
|
-
}
|
|
2448
|
-
catch (_a) {
|
|
2449
|
-
// AbortSignal.prototype.aborted throws if its brand check fails
|
|
2450
|
-
return false;
|
|
2451
|
-
}
|
|
2452
|
-
}
|
|
2453
|
-
|
|
2454
2553
|
/// <reference lib="dom" />
|
|
2455
2554
|
const NativeDOMException = typeof DOMException !== 'undefined' ? DOMException : undefined;
|
|
2456
2555
|
|
|
@@ -2468,6 +2567,7 @@ function isDOMExceptionConstructor(ctor) {
|
|
|
2468
2567
|
}
|
|
2469
2568
|
}
|
|
2470
2569
|
function createDOMExceptionPolyfill() {
|
|
2570
|
+
// eslint-disable-next-line no-shadow
|
|
2471
2571
|
const ctor = function DOMException(message, name) {
|
|
2472
2572
|
this.message = message || '';
|
|
2473
2573
|
this.name = name || 'Error';
|
|
@@ -2479,6 +2579,7 @@ function createDOMExceptionPolyfill() {
|
|
|
2479
2579
|
Object.defineProperty(ctor.prototype, 'constructor', { value: ctor, writable: true, configurable: true });
|
|
2480
2580
|
return ctor;
|
|
2481
2581
|
}
|
|
2582
|
+
// eslint-disable-next-line no-redeclare
|
|
2482
2583
|
const DOMException$1 = isDOMExceptionConstructor(NativeDOMException) ? NativeDOMException : createDOMExceptionPolyfill();
|
|
2483
2584
|
|
|
2484
2585
|
function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
|
|
@@ -2671,7 +2772,7 @@ class ReadableStreamDefaultController {
|
|
|
2671
2772
|
*/
|
|
2672
2773
|
get desiredSize() {
|
|
2673
2774
|
if (!IsReadableStreamDefaultController(this)) {
|
|
2674
|
-
throw defaultControllerBrandCheckException('desiredSize');
|
|
2775
|
+
throw defaultControllerBrandCheckException$1('desiredSize');
|
|
2675
2776
|
}
|
|
2676
2777
|
return ReadableStreamDefaultControllerGetDesiredSize(this);
|
|
2677
2778
|
}
|
|
@@ -2681,7 +2782,7 @@ class ReadableStreamDefaultController {
|
|
|
2681
2782
|
*/
|
|
2682
2783
|
close() {
|
|
2683
2784
|
if (!IsReadableStreamDefaultController(this)) {
|
|
2684
|
-
throw defaultControllerBrandCheckException('close');
|
|
2785
|
+
throw defaultControllerBrandCheckException$1('close');
|
|
2685
2786
|
}
|
|
2686
2787
|
if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
|
|
2687
2788
|
throw new TypeError('The stream is not in a state that permits close');
|
|
@@ -2690,7 +2791,7 @@ class ReadableStreamDefaultController {
|
|
|
2690
2791
|
}
|
|
2691
2792
|
enqueue(chunk = undefined) {
|
|
2692
2793
|
if (!IsReadableStreamDefaultController(this)) {
|
|
2693
|
-
throw defaultControllerBrandCheckException('enqueue');
|
|
2794
|
+
throw defaultControllerBrandCheckException$1('enqueue');
|
|
2694
2795
|
}
|
|
2695
2796
|
if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) {
|
|
2696
2797
|
throw new TypeError('The stream is not in a state that permits enqueue');
|
|
@@ -2702,7 +2803,7 @@ class ReadableStreamDefaultController {
|
|
|
2702
2803
|
*/
|
|
2703
2804
|
error(e = undefined) {
|
|
2704
2805
|
if (!IsReadableStreamDefaultController(this)) {
|
|
2705
|
-
throw defaultControllerBrandCheckException('error');
|
|
2806
|
+
throw defaultControllerBrandCheckException$1('error');
|
|
2706
2807
|
}
|
|
2707
2808
|
ReadableStreamDefaultControllerError(this, e);
|
|
2708
2809
|
}
|
|
@@ -2753,7 +2854,7 @@ function IsReadableStreamDefaultController(x) {
|
|
|
2753
2854
|
if (!Object.prototype.hasOwnProperty.call(x, '_controlledReadableStream')) {
|
|
2754
2855
|
return false;
|
|
2755
2856
|
}
|
|
2756
|
-
return
|
|
2857
|
+
return x instanceof ReadableStreamDefaultController;
|
|
2757
2858
|
}
|
|
2758
2859
|
function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {
|
|
2759
2860
|
const shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller);
|
|
@@ -2909,13 +3010,20 @@ function SetUpReadableStreamDefaultControllerFromUnderlyingSource(stream, underl
|
|
|
2909
3010
|
SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
|
|
2910
3011
|
}
|
|
2911
3012
|
// Helper functions for the ReadableStreamDefaultController.
|
|
2912
|
-
function defaultControllerBrandCheckException(name) {
|
|
3013
|
+
function defaultControllerBrandCheckException$1(name) {
|
|
2913
3014
|
return new TypeError(`ReadableStreamDefaultController.prototype.${name} can only be used on a ReadableStreamDefaultController`);
|
|
2914
3015
|
}
|
|
2915
3016
|
|
|
2916
3017
|
function ReadableStreamTee(stream, cloneForBranch2) {
|
|
3018
|
+
if (IsReadableByteStreamController(stream._readableStreamController)) {
|
|
3019
|
+
return ReadableByteStreamTee(stream);
|
|
3020
|
+
}
|
|
3021
|
+
return ReadableStreamDefaultTee(stream);
|
|
3022
|
+
}
|
|
3023
|
+
function ReadableStreamDefaultTee(stream, cloneForBranch2) {
|
|
2917
3024
|
const reader = AcquireReadableStreamDefaultReader(stream);
|
|
2918
3025
|
let reading = false;
|
|
3026
|
+
let readAgain = false;
|
|
2919
3027
|
let canceled1 = false;
|
|
2920
3028
|
let canceled2 = false;
|
|
2921
3029
|
let reason1;
|
|
@@ -2928,30 +3036,34 @@ function ReadableStreamTee(stream, cloneForBranch2) {
|
|
|
2928
3036
|
});
|
|
2929
3037
|
function pullAlgorithm() {
|
|
2930
3038
|
if (reading) {
|
|
3039
|
+
readAgain = true;
|
|
2931
3040
|
return promiseResolvedWith(undefined);
|
|
2932
3041
|
}
|
|
2933
3042
|
reading = true;
|
|
2934
3043
|
const readRequest = {
|
|
2935
|
-
_chunkSteps:
|
|
3044
|
+
_chunkSteps: chunk => {
|
|
2936
3045
|
// This needs to be delayed a microtask because it takes at least a microtask to detect errors (using
|
|
2937
3046
|
// reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
|
|
2938
3047
|
// successful synchronously-available reads get ahead of asynchronously-available errors.
|
|
2939
3048
|
queueMicrotask(() => {
|
|
2940
|
-
|
|
2941
|
-
const
|
|
2942
|
-
const
|
|
3049
|
+
readAgain = false;
|
|
3050
|
+
const chunk1 = chunk;
|
|
3051
|
+
const chunk2 = chunk;
|
|
2943
3052
|
// There is no way to access the cloning code right now in the reference implementation.
|
|
2944
3053
|
// If we add one then we'll need an implementation for serializable objects.
|
|
2945
3054
|
// if (!canceled2 && cloneForBranch2) {
|
|
2946
|
-
//
|
|
3055
|
+
// chunk2 = StructuredDeserialize(StructuredSerialize(chunk2));
|
|
2947
3056
|
// }
|
|
2948
3057
|
if (!canceled1) {
|
|
2949
|
-
ReadableStreamDefaultControllerEnqueue(branch1._readableStreamController,
|
|
3058
|
+
ReadableStreamDefaultControllerEnqueue(branch1._readableStreamController, chunk1);
|
|
2950
3059
|
}
|
|
2951
3060
|
if (!canceled2) {
|
|
2952
|
-
ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController,
|
|
3061
|
+
ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, chunk2);
|
|
3062
|
+
}
|
|
3063
|
+
reading = false;
|
|
3064
|
+
if (readAgain) {
|
|
3065
|
+
pullAlgorithm();
|
|
2953
3066
|
}
|
|
2954
|
-
resolveCancelPromise(undefined);
|
|
2955
3067
|
});
|
|
2956
3068
|
},
|
|
2957
3069
|
_closeSteps: () => {
|
|
@@ -2962,6 +3074,9 @@ function ReadableStreamTee(stream, cloneForBranch2) {
|
|
|
2962
3074
|
if (!canceled2) {
|
|
2963
3075
|
ReadableStreamDefaultControllerClose(branch2._readableStreamController);
|
|
2964
3076
|
}
|
|
3077
|
+
if (!canceled1 || !canceled2) {
|
|
3078
|
+
resolveCancelPromise(undefined);
|
|
3079
|
+
}
|
|
2965
3080
|
},
|
|
2966
3081
|
_errorSteps: () => {
|
|
2967
3082
|
reading = false;
|
|
@@ -2998,8 +3113,235 @@ function ReadableStreamTee(stream, cloneForBranch2) {
|
|
|
2998
3113
|
uponRejection(reader._closedPromise, (r) => {
|
|
2999
3114
|
ReadableStreamDefaultControllerError(branch1._readableStreamController, r);
|
|
3000
3115
|
ReadableStreamDefaultControllerError(branch2._readableStreamController, r);
|
|
3001
|
-
|
|
3116
|
+
if (!canceled1 || !canceled2) {
|
|
3117
|
+
resolveCancelPromise(undefined);
|
|
3118
|
+
}
|
|
3119
|
+
});
|
|
3120
|
+
return [branch1, branch2];
|
|
3121
|
+
}
|
|
3122
|
+
function ReadableByteStreamTee(stream) {
|
|
3123
|
+
let reader = AcquireReadableStreamDefaultReader(stream);
|
|
3124
|
+
let reading = false;
|
|
3125
|
+
let readAgainForBranch1 = false;
|
|
3126
|
+
let readAgainForBranch2 = false;
|
|
3127
|
+
let canceled1 = false;
|
|
3128
|
+
let canceled2 = false;
|
|
3129
|
+
let reason1;
|
|
3130
|
+
let reason2;
|
|
3131
|
+
let branch1;
|
|
3132
|
+
let branch2;
|
|
3133
|
+
let resolveCancelPromise;
|
|
3134
|
+
const cancelPromise = newPromise(resolve => {
|
|
3135
|
+
resolveCancelPromise = resolve;
|
|
3002
3136
|
});
|
|
3137
|
+
function forwardReaderError(thisReader) {
|
|
3138
|
+
uponRejection(thisReader._closedPromise, r => {
|
|
3139
|
+
if (thisReader !== reader) {
|
|
3140
|
+
return;
|
|
3141
|
+
}
|
|
3142
|
+
ReadableByteStreamControllerError(branch1._readableStreamController, r);
|
|
3143
|
+
ReadableByteStreamControllerError(branch2._readableStreamController, r);
|
|
3144
|
+
if (!canceled1 || !canceled2) {
|
|
3145
|
+
resolveCancelPromise(undefined);
|
|
3146
|
+
}
|
|
3147
|
+
});
|
|
3148
|
+
}
|
|
3149
|
+
function pullWithDefaultReader() {
|
|
3150
|
+
if (IsReadableStreamBYOBReader(reader)) {
|
|
3151
|
+
ReadableStreamReaderGenericRelease(reader);
|
|
3152
|
+
reader = AcquireReadableStreamDefaultReader(stream);
|
|
3153
|
+
forwardReaderError(reader);
|
|
3154
|
+
}
|
|
3155
|
+
const readRequest = {
|
|
3156
|
+
_chunkSteps: chunk => {
|
|
3157
|
+
// This needs to be delayed a microtask because it takes at least a microtask to detect errors (using
|
|
3158
|
+
// reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
|
|
3159
|
+
// successful synchronously-available reads get ahead of asynchronously-available errors.
|
|
3160
|
+
queueMicrotask(() => {
|
|
3161
|
+
readAgainForBranch1 = false;
|
|
3162
|
+
readAgainForBranch2 = false;
|
|
3163
|
+
const chunk1 = chunk;
|
|
3164
|
+
let chunk2 = chunk;
|
|
3165
|
+
if (!canceled1 && !canceled2) {
|
|
3166
|
+
try {
|
|
3167
|
+
chunk2 = CloneAsUint8Array(chunk);
|
|
3168
|
+
}
|
|
3169
|
+
catch (cloneE) {
|
|
3170
|
+
ReadableByteStreamControllerError(branch1._readableStreamController, cloneE);
|
|
3171
|
+
ReadableByteStreamControllerError(branch2._readableStreamController, cloneE);
|
|
3172
|
+
resolveCancelPromise(ReadableStreamCancel(stream, cloneE));
|
|
3173
|
+
return;
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
3176
|
+
if (!canceled1) {
|
|
3177
|
+
ReadableByteStreamControllerEnqueue(branch1._readableStreamController, chunk1);
|
|
3178
|
+
}
|
|
3179
|
+
if (!canceled2) {
|
|
3180
|
+
ReadableByteStreamControllerEnqueue(branch2._readableStreamController, chunk2);
|
|
3181
|
+
}
|
|
3182
|
+
reading = false;
|
|
3183
|
+
if (readAgainForBranch1) {
|
|
3184
|
+
pull1Algorithm();
|
|
3185
|
+
}
|
|
3186
|
+
else if (readAgainForBranch2) {
|
|
3187
|
+
pull2Algorithm();
|
|
3188
|
+
}
|
|
3189
|
+
});
|
|
3190
|
+
},
|
|
3191
|
+
_closeSteps: () => {
|
|
3192
|
+
reading = false;
|
|
3193
|
+
if (!canceled1) {
|
|
3194
|
+
ReadableByteStreamControllerClose(branch1._readableStreamController);
|
|
3195
|
+
}
|
|
3196
|
+
if (!canceled2) {
|
|
3197
|
+
ReadableByteStreamControllerClose(branch2._readableStreamController);
|
|
3198
|
+
}
|
|
3199
|
+
if (branch1._readableStreamController._pendingPullIntos.length > 0) {
|
|
3200
|
+
ReadableByteStreamControllerRespond(branch1._readableStreamController, 0);
|
|
3201
|
+
}
|
|
3202
|
+
if (branch2._readableStreamController._pendingPullIntos.length > 0) {
|
|
3203
|
+
ReadableByteStreamControllerRespond(branch2._readableStreamController, 0);
|
|
3204
|
+
}
|
|
3205
|
+
if (!canceled1 || !canceled2) {
|
|
3206
|
+
resolveCancelPromise(undefined);
|
|
3207
|
+
}
|
|
3208
|
+
},
|
|
3209
|
+
_errorSteps: () => {
|
|
3210
|
+
reading = false;
|
|
3211
|
+
}
|
|
3212
|
+
};
|
|
3213
|
+
ReadableStreamDefaultReaderRead(reader, readRequest);
|
|
3214
|
+
}
|
|
3215
|
+
function pullWithBYOBReader(view, forBranch2) {
|
|
3216
|
+
if (IsReadableStreamDefaultReader(reader)) {
|
|
3217
|
+
ReadableStreamReaderGenericRelease(reader);
|
|
3218
|
+
reader = AcquireReadableStreamBYOBReader(stream);
|
|
3219
|
+
forwardReaderError(reader);
|
|
3220
|
+
}
|
|
3221
|
+
const byobBranch = forBranch2 ? branch2 : branch1;
|
|
3222
|
+
const otherBranch = forBranch2 ? branch1 : branch2;
|
|
3223
|
+
const readIntoRequest = {
|
|
3224
|
+
_chunkSteps: chunk => {
|
|
3225
|
+
// This needs to be delayed a microtask because it takes at least a microtask to detect errors (using
|
|
3226
|
+
// reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
|
|
3227
|
+
// successful synchronously-available reads get ahead of asynchronously-available errors.
|
|
3228
|
+
queueMicrotask(() => {
|
|
3229
|
+
readAgainForBranch1 = false;
|
|
3230
|
+
readAgainForBranch2 = false;
|
|
3231
|
+
const byobCanceled = forBranch2 ? canceled2 : canceled1;
|
|
3232
|
+
const otherCanceled = forBranch2 ? canceled1 : canceled2;
|
|
3233
|
+
if (!otherCanceled) {
|
|
3234
|
+
let clonedChunk;
|
|
3235
|
+
try {
|
|
3236
|
+
clonedChunk = CloneAsUint8Array(chunk);
|
|
3237
|
+
}
|
|
3238
|
+
catch (cloneE) {
|
|
3239
|
+
ReadableByteStreamControllerError(byobBranch._readableStreamController, cloneE);
|
|
3240
|
+
ReadableByteStreamControllerError(otherBranch._readableStreamController, cloneE);
|
|
3241
|
+
resolveCancelPromise(ReadableStreamCancel(stream, cloneE));
|
|
3242
|
+
return;
|
|
3243
|
+
}
|
|
3244
|
+
if (!byobCanceled) {
|
|
3245
|
+
ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk);
|
|
3246
|
+
}
|
|
3247
|
+
ReadableByteStreamControllerEnqueue(otherBranch._readableStreamController, clonedChunk);
|
|
3248
|
+
}
|
|
3249
|
+
else if (!byobCanceled) {
|
|
3250
|
+
ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk);
|
|
3251
|
+
}
|
|
3252
|
+
reading = false;
|
|
3253
|
+
if (readAgainForBranch1) {
|
|
3254
|
+
pull1Algorithm();
|
|
3255
|
+
}
|
|
3256
|
+
else if (readAgainForBranch2) {
|
|
3257
|
+
pull2Algorithm();
|
|
3258
|
+
}
|
|
3259
|
+
});
|
|
3260
|
+
},
|
|
3261
|
+
_closeSteps: chunk => {
|
|
3262
|
+
reading = false;
|
|
3263
|
+
const byobCanceled = forBranch2 ? canceled2 : canceled1;
|
|
3264
|
+
const otherCanceled = forBranch2 ? canceled1 : canceled2;
|
|
3265
|
+
if (!byobCanceled) {
|
|
3266
|
+
ReadableByteStreamControllerClose(byobBranch._readableStreamController);
|
|
3267
|
+
}
|
|
3268
|
+
if (!otherCanceled) {
|
|
3269
|
+
ReadableByteStreamControllerClose(otherBranch._readableStreamController);
|
|
3270
|
+
}
|
|
3271
|
+
if (chunk !== undefined) {
|
|
3272
|
+
if (!byobCanceled) {
|
|
3273
|
+
ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk);
|
|
3274
|
+
}
|
|
3275
|
+
if (!otherCanceled && otherBranch._readableStreamController._pendingPullIntos.length > 0) {
|
|
3276
|
+
ReadableByteStreamControllerRespond(otherBranch._readableStreamController, 0);
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
if (!byobCanceled || !otherCanceled) {
|
|
3280
|
+
resolveCancelPromise(undefined);
|
|
3281
|
+
}
|
|
3282
|
+
},
|
|
3283
|
+
_errorSteps: () => {
|
|
3284
|
+
reading = false;
|
|
3285
|
+
}
|
|
3286
|
+
};
|
|
3287
|
+
ReadableStreamBYOBReaderRead(reader, view, readIntoRequest);
|
|
3288
|
+
}
|
|
3289
|
+
function pull1Algorithm() {
|
|
3290
|
+
if (reading) {
|
|
3291
|
+
readAgainForBranch1 = true;
|
|
3292
|
+
return promiseResolvedWith(undefined);
|
|
3293
|
+
}
|
|
3294
|
+
reading = true;
|
|
3295
|
+
const byobRequest = ReadableByteStreamControllerGetBYOBRequest(branch1._readableStreamController);
|
|
3296
|
+
if (byobRequest === null) {
|
|
3297
|
+
pullWithDefaultReader();
|
|
3298
|
+
}
|
|
3299
|
+
else {
|
|
3300
|
+
pullWithBYOBReader(byobRequest._view, false);
|
|
3301
|
+
}
|
|
3302
|
+
return promiseResolvedWith(undefined);
|
|
3303
|
+
}
|
|
3304
|
+
function pull2Algorithm() {
|
|
3305
|
+
if (reading) {
|
|
3306
|
+
readAgainForBranch2 = true;
|
|
3307
|
+
return promiseResolvedWith(undefined);
|
|
3308
|
+
}
|
|
3309
|
+
reading = true;
|
|
3310
|
+
const byobRequest = ReadableByteStreamControllerGetBYOBRequest(branch2._readableStreamController);
|
|
3311
|
+
if (byobRequest === null) {
|
|
3312
|
+
pullWithDefaultReader();
|
|
3313
|
+
}
|
|
3314
|
+
else {
|
|
3315
|
+
pullWithBYOBReader(byobRequest._view, true);
|
|
3316
|
+
}
|
|
3317
|
+
return promiseResolvedWith(undefined);
|
|
3318
|
+
}
|
|
3319
|
+
function cancel1Algorithm(reason) {
|
|
3320
|
+
canceled1 = true;
|
|
3321
|
+
reason1 = reason;
|
|
3322
|
+
if (canceled2) {
|
|
3323
|
+
const compositeReason = CreateArrayFromList([reason1, reason2]);
|
|
3324
|
+
const cancelResult = ReadableStreamCancel(stream, compositeReason);
|
|
3325
|
+
resolveCancelPromise(cancelResult);
|
|
3326
|
+
}
|
|
3327
|
+
return cancelPromise;
|
|
3328
|
+
}
|
|
3329
|
+
function cancel2Algorithm(reason) {
|
|
3330
|
+
canceled2 = true;
|
|
3331
|
+
reason2 = reason;
|
|
3332
|
+
if (canceled1) {
|
|
3333
|
+
const compositeReason = CreateArrayFromList([reason1, reason2]);
|
|
3334
|
+
const cancelResult = ReadableStreamCancel(stream, compositeReason);
|
|
3335
|
+
resolveCancelPromise(cancelResult);
|
|
3336
|
+
}
|
|
3337
|
+
return cancelPromise;
|
|
3338
|
+
}
|
|
3339
|
+
function startAlgorithm() {
|
|
3340
|
+
return;
|
|
3341
|
+
}
|
|
3342
|
+
branch1 = CreateReadableByteStream(startAlgorithm, pull1Algorithm, cancel1Algorithm);
|
|
3343
|
+
branch2 = CreateReadableByteStream(startAlgorithm, pull2Algorithm, cancel2Algorithm);
|
|
3344
|
+
forwardReaderError(reader);
|
|
3003
3345
|
return [branch1, branch2];
|
|
3004
3346
|
}
|
|
3005
3347
|
|
|
@@ -3263,6 +3605,14 @@ function CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, hi
|
|
|
3263
3605
|
SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
|
|
3264
3606
|
return stream;
|
|
3265
3607
|
}
|
|
3608
|
+
// Throws if and only if startAlgorithm throws.
|
|
3609
|
+
function CreateReadableByteStream(startAlgorithm, pullAlgorithm, cancelAlgorithm) {
|
|
3610
|
+
const stream = Object.create(ReadableStream.prototype);
|
|
3611
|
+
InitializeReadableStream(stream);
|
|
3612
|
+
const controller = Object.create(ReadableByteStreamController.prototype);
|
|
3613
|
+
SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, 0, undefined);
|
|
3614
|
+
return stream;
|
|
3615
|
+
}
|
|
3266
3616
|
function InitializeReadableStream(stream) {
|
|
3267
3617
|
stream._state = 'readable';
|
|
3268
3618
|
stream._reader = undefined;
|
|
@@ -3276,7 +3626,7 @@ function IsReadableStream(x) {
|
|
|
3276
3626
|
if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) {
|
|
3277
3627
|
return false;
|
|
3278
3628
|
}
|
|
3279
|
-
return
|
|
3629
|
+
return x instanceof ReadableStream;
|
|
3280
3630
|
}
|
|
3281
3631
|
function IsReadableStreamLocked(stream) {
|
|
3282
3632
|
if (stream._reader === undefined) {
|
|
@@ -3294,6 +3644,13 @@ function ReadableStreamCancel(stream, reason) {
|
|
|
3294
3644
|
return promiseRejectedWith(stream._storedError);
|
|
3295
3645
|
}
|
|
3296
3646
|
ReadableStreamClose(stream);
|
|
3647
|
+
const reader = stream._reader;
|
|
3648
|
+
if (reader !== undefined && IsReadableStreamBYOBReader(reader)) {
|
|
3649
|
+
reader._readIntoRequests.forEach(readIntoRequest => {
|
|
3650
|
+
readIntoRequest._closeSteps(undefined);
|
|
3651
|
+
});
|
|
3652
|
+
reader._readIntoRequests = new SimpleQueue();
|
|
3653
|
+
}
|
|
3297
3654
|
const sourceCancelPromise = stream._readableStreamController[CancelSteps](reason);
|
|
3298
3655
|
return transformPromiseWith(sourceCancelPromise, noop);
|
|
3299
3656
|
}
|
|
@@ -3346,9 +3703,14 @@ function convertQueuingStrategyInit(init, context) {
|
|
|
3346
3703
|
};
|
|
3347
3704
|
}
|
|
3348
3705
|
|
|
3349
|
-
|
|
3706
|
+
// The size function must not have a prototype property nor be a constructor
|
|
3707
|
+
const byteLengthSizeFunction = (chunk) => {
|
|
3350
3708
|
return chunk.byteLength;
|
|
3351
3709
|
};
|
|
3710
|
+
Object.defineProperty(byteLengthSizeFunction, 'name', {
|
|
3711
|
+
value: 'size',
|
|
3712
|
+
configurable: true
|
|
3713
|
+
});
|
|
3352
3714
|
/**
|
|
3353
3715
|
* A queuing strategy that counts the number of bytes in each chunk.
|
|
3354
3716
|
*
|
|
@@ -3400,12 +3762,17 @@ function IsByteLengthQueuingStrategy(x) {
|
|
|
3400
3762
|
if (!Object.prototype.hasOwnProperty.call(x, '_byteLengthQueuingStrategyHighWaterMark')) {
|
|
3401
3763
|
return false;
|
|
3402
3764
|
}
|
|
3403
|
-
return
|
|
3765
|
+
return x instanceof ByteLengthQueuingStrategy;
|
|
3404
3766
|
}
|
|
3405
3767
|
|
|
3406
|
-
|
|
3768
|
+
// The size function must not have a prototype property nor be a constructor
|
|
3769
|
+
const countSizeFunction = () => {
|
|
3407
3770
|
return 1;
|
|
3408
3771
|
};
|
|
3772
|
+
Object.defineProperty(countSizeFunction, 'name', {
|
|
3773
|
+
value: 'size',
|
|
3774
|
+
configurable: true
|
|
3775
|
+
});
|
|
3409
3776
|
/**
|
|
3410
3777
|
* A queuing strategy that counts the number of chunks.
|
|
3411
3778
|
*
|
|
@@ -3458,7 +3825,7 @@ function IsCountQueuingStrategy(x) {
|
|
|
3458
3825
|
if (!Object.prototype.hasOwnProperty.call(x, '_countQueuingStrategyHighWaterMark')) {
|
|
3459
3826
|
return false;
|
|
3460
3827
|
}
|
|
3461
|
-
return
|
|
3828
|
+
return x instanceof CountQueuingStrategy;
|
|
3462
3829
|
}
|
|
3463
3830
|
|
|
3464
3831
|
function convertTransformer(original, context) {
|
|
@@ -3540,7 +3907,7 @@ class TransformStream {
|
|
|
3540
3907
|
*/
|
|
3541
3908
|
get readable() {
|
|
3542
3909
|
if (!IsTransformStream(this)) {
|
|
3543
|
-
throw streamBrandCheckException
|
|
3910
|
+
throw streamBrandCheckException('readable');
|
|
3544
3911
|
}
|
|
3545
3912
|
return this._readable;
|
|
3546
3913
|
}
|
|
@@ -3549,7 +3916,7 @@ class TransformStream {
|
|
|
3549
3916
|
*/
|
|
3550
3917
|
get writable() {
|
|
3551
3918
|
if (!IsTransformStream(this)) {
|
|
3552
|
-
throw streamBrandCheckException
|
|
3919
|
+
throw streamBrandCheckException('writable');
|
|
3553
3920
|
}
|
|
3554
3921
|
return this._writable;
|
|
3555
3922
|
}
|
|
@@ -3600,7 +3967,7 @@ function IsTransformStream(x) {
|
|
|
3600
3967
|
if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) {
|
|
3601
3968
|
return false;
|
|
3602
3969
|
}
|
|
3603
|
-
return
|
|
3970
|
+
return x instanceof TransformStream;
|
|
3604
3971
|
}
|
|
3605
3972
|
// This is a no-op if both sides are already errored.
|
|
3606
3973
|
function TransformStreamError(stream, e) {
|
|
@@ -3642,14 +4009,14 @@ class TransformStreamDefaultController {
|
|
|
3642
4009
|
*/
|
|
3643
4010
|
get desiredSize() {
|
|
3644
4011
|
if (!IsTransformStreamDefaultController(this)) {
|
|
3645
|
-
throw defaultControllerBrandCheckException
|
|
4012
|
+
throw defaultControllerBrandCheckException('desiredSize');
|
|
3646
4013
|
}
|
|
3647
4014
|
const readableController = this._controlledTransformStream._readable._readableStreamController;
|
|
3648
4015
|
return ReadableStreamDefaultControllerGetDesiredSize(readableController);
|
|
3649
4016
|
}
|
|
3650
4017
|
enqueue(chunk = undefined) {
|
|
3651
4018
|
if (!IsTransformStreamDefaultController(this)) {
|
|
3652
|
-
throw defaultControllerBrandCheckException
|
|
4019
|
+
throw defaultControllerBrandCheckException('enqueue');
|
|
3653
4020
|
}
|
|
3654
4021
|
TransformStreamDefaultControllerEnqueue(this, chunk);
|
|
3655
4022
|
}
|
|
@@ -3659,7 +4026,7 @@ class TransformStreamDefaultController {
|
|
|
3659
4026
|
*/
|
|
3660
4027
|
error(reason = undefined) {
|
|
3661
4028
|
if (!IsTransformStreamDefaultController(this)) {
|
|
3662
|
-
throw defaultControllerBrandCheckException
|
|
4029
|
+
throw defaultControllerBrandCheckException('error');
|
|
3663
4030
|
}
|
|
3664
4031
|
TransformStreamDefaultControllerError(this, reason);
|
|
3665
4032
|
}
|
|
@@ -3669,7 +4036,7 @@ class TransformStreamDefaultController {
|
|
|
3669
4036
|
*/
|
|
3670
4037
|
terminate() {
|
|
3671
4038
|
if (!IsTransformStreamDefaultController(this)) {
|
|
3672
|
-
throw defaultControllerBrandCheckException
|
|
4039
|
+
throw defaultControllerBrandCheckException('terminate');
|
|
3673
4040
|
}
|
|
3674
4041
|
TransformStreamDefaultControllerTerminate(this);
|
|
3675
4042
|
}
|
|
@@ -3694,7 +4061,7 @@ function IsTransformStreamDefaultController(x) {
|
|
|
3694
4061
|
if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) {
|
|
3695
4062
|
return false;
|
|
3696
4063
|
}
|
|
3697
|
-
return
|
|
4064
|
+
return x instanceof TransformStreamDefaultController;
|
|
3698
4065
|
}
|
|
3699
4066
|
function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm) {
|
|
3700
4067
|
controller._controlledTransformStream = stream;
|
|
@@ -3811,11 +4178,11 @@ function TransformStreamDefaultSourcePullAlgorithm(stream) {
|
|
|
3811
4178
|
return stream._backpressureChangePromise;
|
|
3812
4179
|
}
|
|
3813
4180
|
// Helper functions for the TransformStreamDefaultController.
|
|
3814
|
-
function defaultControllerBrandCheckException
|
|
4181
|
+
function defaultControllerBrandCheckException(name) {
|
|
3815
4182
|
return new TypeError(`TransformStreamDefaultController.prototype.${name} can only be used on a TransformStreamDefaultController`);
|
|
3816
4183
|
}
|
|
3817
4184
|
// Helper functions for the TransformStream.
|
|
3818
|
-
function streamBrandCheckException
|
|
4185
|
+
function streamBrandCheckException(name) {
|
|
3819
4186
|
return new TypeError(`TransformStream.prototype.${name} can only be used on a TransformStream`);
|
|
3820
4187
|
}
|
|
3821
4188
|
|