web-streams-polyfill 3.2.1 → 3.3.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/LICENSE +1 -1
- package/README.md +11 -14
- package/dist/polyfill.es2018.js +723 -197
- package/dist/polyfill.es2018.js.map +1 -1
- package/dist/polyfill.es2018.min.js +8 -1
- package/dist/polyfill.es2018.min.js.map +1 -1
- package/dist/polyfill.es2018.mjs +721 -193
- package/dist/polyfill.es2018.mjs.map +1 -1
- package/dist/polyfill.es6.js +789 -197
- package/dist/polyfill.es6.js.map +1 -1
- package/dist/polyfill.es6.min.js +8 -1
- package/dist/polyfill.es6.min.js.map +1 -1
- package/dist/polyfill.es6.mjs +787 -193
- package/dist/polyfill.es6.mjs.map +1 -1
- package/dist/polyfill.js +873 -243
- package/dist/polyfill.js.map +1 -1
- package/dist/polyfill.min.js +8 -1
- package/dist/polyfill.min.js.map +1 -1
- package/dist/polyfill.mjs +871 -239
- package/dist/polyfill.mjs.map +1 -1
- package/dist/ponyfill.es2018.js +723 -197
- package/dist/ponyfill.es2018.js.map +1 -1
- package/dist/ponyfill.es2018.mjs +721 -193
- package/dist/ponyfill.es2018.mjs.map +1 -1
- package/dist/ponyfill.es6.js +789 -197
- package/dist/ponyfill.es6.js.map +1 -1
- package/dist/ponyfill.es6.mjs +787 -193
- package/dist/ponyfill.es6.mjs.map +1 -1
- package/dist/ponyfill.js +873 -243
- package/dist/ponyfill.js.map +1 -1
- package/dist/ponyfill.mjs +871 -239
- package/dist/ponyfill.mjs.map +1 -1
- package/es2018/package.json +1 -1
- package/es6/package.json +1 -1
- package/package.json +30 -32
- package/ponyfill/es2018/package.json +1 -1
- package/ponyfill/es6/package.json +1 -1
- package/ponyfill/package.json +1 -1
- package/types/polyfill.d.ts +29 -0
- package/{dist/types/ts3.6/polyfill.d.ts → types/ponyfill.d.ts} +57 -7
- package/{dist/types → types}/tsdoc-metadata.json +1 -1
- package/dist/types/polyfill.d.ts +0 -771
package/dist/polyfill.js
CHANGED
|
@@ -1,50 +1,146 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @license
|
|
3
|
+
* web-streams-polyfill v3.3.0
|
|
4
|
+
* Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
|
|
5
|
+
* This code is released under the MIT license.
|
|
6
|
+
* SPDX-License-Identifier: MIT
|
|
3
7
|
*/
|
|
4
8
|
(function (global, factory) {
|
|
5
9
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
6
10
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
7
11
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.WebStreamsPolyfill = {}));
|
|
8
|
-
}(this, (function (exports) { 'use strict';
|
|
12
|
+
})(this, (function (exports) { 'use strict';
|
|
9
13
|
|
|
10
14
|
/// <reference lib="es2015.symbol" />
|
|
11
15
|
var SymbolPolyfill = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ?
|
|
12
16
|
Symbol :
|
|
13
|
-
function (description) { return "Symbol("
|
|
17
|
+
function (description) { return "Symbol(".concat(description, ")"); };
|
|
18
|
+
|
|
19
|
+
/******************************************************************************
|
|
20
|
+
Copyright (c) Microsoft Corporation.
|
|
21
|
+
|
|
22
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
23
|
+
purpose with or without fee is hereby granted.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
26
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
27
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
28
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
29
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
30
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
31
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
32
|
+
***************************************************************************** */
|
|
33
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
function __generator(thisArg, body) {
|
|
37
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
38
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
39
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
40
|
+
function step(op) {
|
|
41
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
42
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
43
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
44
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
45
|
+
switch (op[0]) {
|
|
46
|
+
case 0: case 1: t = op; break;
|
|
47
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
48
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
49
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
50
|
+
default:
|
|
51
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
52
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
53
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
54
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
55
|
+
if (t[2]) _.ops.pop();
|
|
56
|
+
_.trys.pop(); continue;
|
|
57
|
+
}
|
|
58
|
+
op = body.call(thisArg, _);
|
|
59
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
60
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function __values(o) {
|
|
65
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
66
|
+
if (m) return m.call(o);
|
|
67
|
+
if (o && typeof o.length === "number") return {
|
|
68
|
+
next: function () {
|
|
69
|
+
if (o && i >= o.length) o = void 0;
|
|
70
|
+
return { value: o && o[i++], done: !o };
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function __await(v) {
|
|
77
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
81
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
82
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
83
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
84
|
+
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
85
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
86
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
87
|
+
function fulfill(value) { resume("next", value); }
|
|
88
|
+
function reject(value) { resume("throw", value); }
|
|
89
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function __asyncDelegator(o) {
|
|
93
|
+
var i, p;
|
|
94
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
95
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function __asyncValues(o) {
|
|
99
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
100
|
+
var m = o[Symbol.asyncIterator], i;
|
|
101
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
102
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
103
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
107
|
+
var e = new Error(message);
|
|
108
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
109
|
+
};
|
|
14
110
|
|
|
15
|
-
/// <reference lib="dom" />
|
|
16
111
|
function noop() {
|
|
17
112
|
return undefined;
|
|
18
113
|
}
|
|
19
|
-
function getGlobals() {
|
|
20
|
-
if (typeof self !== 'undefined') {
|
|
21
|
-
return self;
|
|
22
|
-
}
|
|
23
|
-
else if (typeof window !== 'undefined') {
|
|
24
|
-
return window;
|
|
25
|
-
}
|
|
26
|
-
else if (typeof global !== 'undefined') {
|
|
27
|
-
return global;
|
|
28
|
-
}
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
var globals = getGlobals();
|
|
32
114
|
|
|
33
115
|
function typeIsObject(x) {
|
|
34
116
|
return (typeof x === 'object' && x !== null) || typeof x === 'function';
|
|
35
117
|
}
|
|
36
118
|
var rethrowAssertionErrorRejection = noop;
|
|
119
|
+
function setFunctionName(fn, name) {
|
|
120
|
+
try {
|
|
121
|
+
Object.defineProperty(fn, 'name', {
|
|
122
|
+
value: name,
|
|
123
|
+
configurable: true
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
catch (_a) {
|
|
127
|
+
// This property is non-configurable in older browsers, so ignore if this throws.
|
|
128
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#browser_compatibility
|
|
129
|
+
}
|
|
130
|
+
}
|
|
37
131
|
|
|
38
132
|
var originalPromise = Promise;
|
|
39
133
|
var originalPromiseThen = Promise.prototype.then;
|
|
40
|
-
var originalPromiseResolve = Promise.resolve.bind(originalPromise);
|
|
41
134
|
var originalPromiseReject = Promise.reject.bind(originalPromise);
|
|
135
|
+
// https://webidl.spec.whatwg.org/#a-new-promise
|
|
42
136
|
function newPromise(executor) {
|
|
43
137
|
return new originalPromise(executor);
|
|
44
138
|
}
|
|
139
|
+
// https://webidl.spec.whatwg.org/#a-promise-resolved-with
|
|
45
140
|
function promiseResolvedWith(value) {
|
|
46
|
-
return
|
|
141
|
+
return newPromise(function (resolve) { return resolve(value); });
|
|
47
142
|
}
|
|
143
|
+
// https://webidl.spec.whatwg.org/#a-promise-rejected-with
|
|
48
144
|
function promiseRejectedWith(reason) {
|
|
49
145
|
return originalPromiseReject(reason);
|
|
50
146
|
}
|
|
@@ -53,6 +149,9 @@
|
|
|
53
149
|
// approximation.
|
|
54
150
|
return originalPromiseThen.call(promise, onFulfilled, onRejected);
|
|
55
151
|
}
|
|
152
|
+
// Bluebird logs a warning when a promise is created within a fulfillment handler, but then isn't returned
|
|
153
|
+
// from that handler. To prevent this, return null instead of void from all handlers.
|
|
154
|
+
// http://bluebirdjs.com/docs/warning-explanations.html#warning-a-promise-was-created-in-a-handler-but-was-not-returned-from-it
|
|
56
155
|
function uponPromise(promise, onFulfilled, onRejected) {
|
|
57
156
|
PerformPromiseThen(PerformPromiseThen(promise, onFulfilled, onRejected), undefined, rethrowAssertionErrorRejection);
|
|
58
157
|
}
|
|
@@ -68,14 +167,16 @@
|
|
|
68
167
|
function setPromiseIsHandledToTrue(promise) {
|
|
69
168
|
PerformPromiseThen(promise, undefined, rethrowAssertionErrorRejection);
|
|
70
169
|
}
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
170
|
+
var _queueMicrotask = function (callback) {
|
|
171
|
+
if (typeof queueMicrotask === 'function') {
|
|
172
|
+
_queueMicrotask = queueMicrotask;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
var resolvedPromise_1 = promiseResolvedWith(undefined);
|
|
176
|
+
_queueMicrotask = function (cb) { return PerformPromiseThen(resolvedPromise_1, cb); };
|
|
75
177
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
})();
|
|
178
|
+
return _queueMicrotask(callback);
|
|
179
|
+
};
|
|
79
180
|
function reflectCall(F, V, args) {
|
|
80
181
|
if (typeof F !== 'function') {
|
|
81
182
|
throw new TypeError('Argument is not a function');
|
|
@@ -204,6 +305,12 @@
|
|
|
204
305
|
return SimpleQueue;
|
|
205
306
|
}());
|
|
206
307
|
|
|
308
|
+
var AbortSteps = SymbolPolyfill('[[AbortSteps]]');
|
|
309
|
+
var ErrorSteps = SymbolPolyfill('[[ErrorSteps]]');
|
|
310
|
+
var CancelSteps = SymbolPolyfill('[[CancelSteps]]');
|
|
311
|
+
var PullSteps = SymbolPolyfill('[[PullSteps]]');
|
|
312
|
+
var ReleaseSteps = SymbolPolyfill('[[ReleaseSteps]]');
|
|
313
|
+
|
|
207
314
|
function ReadableStreamReaderGenericInitialize(reader, stream) {
|
|
208
315
|
reader._ownerReadableStream = stream;
|
|
209
316
|
stream._reader = reader;
|
|
@@ -224,13 +331,15 @@
|
|
|
224
331
|
return ReadableStreamCancel(stream, reason);
|
|
225
332
|
}
|
|
226
333
|
function ReadableStreamReaderGenericRelease(reader) {
|
|
227
|
-
|
|
334
|
+
var stream = reader._ownerReadableStream;
|
|
335
|
+
if (stream._state === 'readable') {
|
|
228
336
|
defaultReaderClosedPromiseReject(reader, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"));
|
|
229
337
|
}
|
|
230
338
|
else {
|
|
231
339
|
defaultReaderClosedPromiseResetToRejected(reader, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"));
|
|
232
340
|
}
|
|
233
|
-
|
|
341
|
+
stream._readableStreamController[ReleaseSteps]();
|
|
342
|
+
stream._reader = undefined;
|
|
234
343
|
reader._ownerReadableStream = undefined;
|
|
235
344
|
}
|
|
236
345
|
// Helper functions for the readers.
|
|
@@ -273,11 +382,6 @@
|
|
|
273
382
|
reader._closedPromise_reject = undefined;
|
|
274
383
|
}
|
|
275
384
|
|
|
276
|
-
var AbortSteps = SymbolPolyfill('[[AbortSteps]]');
|
|
277
|
-
var ErrorSteps = SymbolPolyfill('[[ErrorSteps]]');
|
|
278
|
-
var CancelSteps = SymbolPolyfill('[[CancelSteps]]');
|
|
279
|
-
var PullSteps = SymbolPolyfill('[[PullSteps]]');
|
|
280
|
-
|
|
281
385
|
/// <reference lib="es2015.core" />
|
|
282
386
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite#Polyfill
|
|
283
387
|
var NumberIsFinite = Number.isFinite || function (x) {
|
|
@@ -296,13 +400,13 @@
|
|
|
296
400
|
}
|
|
297
401
|
function assertDictionary(obj, context) {
|
|
298
402
|
if (obj !== undefined && !isDictionary(obj)) {
|
|
299
|
-
throw new TypeError(context
|
|
403
|
+
throw new TypeError("".concat(context, " is not an object."));
|
|
300
404
|
}
|
|
301
405
|
}
|
|
302
406
|
// https://heycam.github.io/webidl/#idl-callback-functions
|
|
303
407
|
function assertFunction(x, context) {
|
|
304
408
|
if (typeof x !== 'function') {
|
|
305
|
-
throw new TypeError(context
|
|
409
|
+
throw new TypeError("".concat(context, " is not a function."));
|
|
306
410
|
}
|
|
307
411
|
}
|
|
308
412
|
// https://heycam.github.io/webidl/#idl-object
|
|
@@ -311,17 +415,17 @@
|
|
|
311
415
|
}
|
|
312
416
|
function assertObject(x, context) {
|
|
313
417
|
if (!isObject(x)) {
|
|
314
|
-
throw new TypeError(context
|
|
418
|
+
throw new TypeError("".concat(context, " is not an object."));
|
|
315
419
|
}
|
|
316
420
|
}
|
|
317
421
|
function assertRequiredArgument(x, position, context) {
|
|
318
422
|
if (x === undefined) {
|
|
319
|
-
throw new TypeError("Parameter "
|
|
423
|
+
throw new TypeError("Parameter ".concat(position, " is required in '").concat(context, "'."));
|
|
320
424
|
}
|
|
321
425
|
}
|
|
322
426
|
function assertRequiredField(x, field, context) {
|
|
323
427
|
if (x === undefined) {
|
|
324
|
-
throw new TypeError(field
|
|
428
|
+
throw new TypeError("".concat(field, " is required in '").concat(context, "'."));
|
|
325
429
|
}
|
|
326
430
|
}
|
|
327
431
|
// https://heycam.github.io/webidl/#idl-unrestricted-double
|
|
@@ -341,11 +445,11 @@
|
|
|
341
445
|
var x = Number(value);
|
|
342
446
|
x = censorNegativeZero(x);
|
|
343
447
|
if (!NumberIsFinite(x)) {
|
|
344
|
-
throw new TypeError(context
|
|
448
|
+
throw new TypeError("".concat(context, " is not a finite number"));
|
|
345
449
|
}
|
|
346
450
|
x = integerPart(x);
|
|
347
451
|
if (x < lowerBound || x > upperBound) {
|
|
348
|
-
throw new TypeError(context
|
|
452
|
+
throw new TypeError("".concat(context, " is outside the accepted range of ").concat(lowerBound, " to ").concat(upperBound, ", inclusive"));
|
|
349
453
|
}
|
|
350
454
|
if (!NumberIsFinite(x) || x === 0) {
|
|
351
455
|
return 0;
|
|
@@ -359,7 +463,7 @@
|
|
|
359
463
|
|
|
360
464
|
function assertReadableStream(x, context) {
|
|
361
465
|
if (!IsReadableStream(x)) {
|
|
362
|
-
throw new TypeError(context
|
|
466
|
+
throw new TypeError("".concat(context, " is not a ReadableStream."));
|
|
363
467
|
}
|
|
364
468
|
}
|
|
365
469
|
|
|
@@ -478,10 +582,7 @@
|
|
|
478
582
|
if (this._ownerReadableStream === undefined) {
|
|
479
583
|
return;
|
|
480
584
|
}
|
|
481
|
-
|
|
482
|
-
throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
|
|
483
|
-
}
|
|
484
|
-
ReadableStreamReaderGenericRelease(this);
|
|
585
|
+
ReadableStreamDefaultReaderRelease(this);
|
|
485
586
|
};
|
|
486
587
|
return ReadableStreamDefaultReader;
|
|
487
588
|
}());
|
|
@@ -491,6 +592,9 @@
|
|
|
491
592
|
releaseLock: { enumerable: true },
|
|
492
593
|
closed: { enumerable: true }
|
|
493
594
|
});
|
|
595
|
+
setFunctionName(ReadableStreamDefaultReader.prototype.cancel, 'cancel');
|
|
596
|
+
setFunctionName(ReadableStreamDefaultReader.prototype.read, 'read');
|
|
597
|
+
setFunctionName(ReadableStreamDefaultReader.prototype.releaseLock, 'releaseLock');
|
|
494
598
|
if (typeof SymbolPolyfill.toStringTag === 'symbol') {
|
|
495
599
|
Object.defineProperty(ReadableStreamDefaultReader.prototype, SymbolPolyfill.toStringTag, {
|
|
496
600
|
value: 'ReadableStreamDefaultReader',
|
|
@@ -520,9 +624,21 @@
|
|
|
520
624
|
stream._readableStreamController[PullSteps](readRequest);
|
|
521
625
|
}
|
|
522
626
|
}
|
|
627
|
+
function ReadableStreamDefaultReaderRelease(reader) {
|
|
628
|
+
ReadableStreamReaderGenericRelease(reader);
|
|
629
|
+
var e = new TypeError('Reader was released');
|
|
630
|
+
ReadableStreamDefaultReaderErrorReadRequests(reader, e);
|
|
631
|
+
}
|
|
632
|
+
function ReadableStreamDefaultReaderErrorReadRequests(reader, e) {
|
|
633
|
+
var readRequests = reader._readRequests;
|
|
634
|
+
reader._readRequests = new SimpleQueue();
|
|
635
|
+
readRequests.forEach(function (readRequest) {
|
|
636
|
+
readRequest._errorSteps(e);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
523
639
|
// Helper functions for the ReadableStreamDefaultReader.
|
|
524
640
|
function defaultReaderBrandCheckException(name) {
|
|
525
|
-
return new TypeError("ReadableStreamDefaultReader.prototype."
|
|
641
|
+
return new TypeError("ReadableStreamDefaultReader.prototype.".concat(name, " can only be used on a ReadableStreamDefaultReader"));
|
|
526
642
|
}
|
|
527
643
|
|
|
528
644
|
/// <reference lib="es2018.asynciterable" />
|
|
@@ -570,9 +686,6 @@
|
|
|
570
686
|
return Promise.resolve({ value: undefined, done: true });
|
|
571
687
|
}
|
|
572
688
|
var reader = this._reader;
|
|
573
|
-
if (reader._ownerReadableStream === undefined) {
|
|
574
|
-
return promiseRejectedWith(readerLockException('iterate'));
|
|
575
|
-
}
|
|
576
689
|
var resolvePromise;
|
|
577
690
|
var rejectPromise;
|
|
578
691
|
var promise = newPromise(function (resolve, reject) {
|
|
@@ -584,7 +697,7 @@
|
|
|
584
697
|
_this._ongoingPromise = undefined;
|
|
585
698
|
// This needs to be delayed by one microtask, otherwise we stop pulling too early which breaks a test.
|
|
586
699
|
// FIXME Is this a bug in the specification, or in the test?
|
|
587
|
-
|
|
700
|
+
_queueMicrotask(function () { return resolvePromise({ value: chunk, done: false }); });
|
|
588
701
|
},
|
|
589
702
|
_closeSteps: function () {
|
|
590
703
|
_this._ongoingPromise = undefined;
|
|
@@ -608,9 +721,6 @@
|
|
|
608
721
|
}
|
|
609
722
|
this._isFinished = true;
|
|
610
723
|
var reader = this._reader;
|
|
611
|
-
if (reader._ownerReadableStream === undefined) {
|
|
612
|
-
return promiseRejectedWith(readerLockException('finish iterating'));
|
|
613
|
-
}
|
|
614
724
|
if (!this._preventCancel) {
|
|
615
725
|
var result = ReadableStreamReaderGenericCancel(reader, value);
|
|
616
726
|
ReadableStreamReaderGenericRelease(reader);
|
|
@@ -664,7 +774,7 @@
|
|
|
664
774
|
}
|
|
665
775
|
// Helper functions for the ReadableStream.
|
|
666
776
|
function streamAsyncIteratorBrandCheckException(name) {
|
|
667
|
-
return new TypeError("ReadableStreamAsyncIterator."
|
|
777
|
+
return new TypeError("ReadableStreamAsyncIterator.".concat(name, " can only be used on a ReadableSteamAsyncIterator"));
|
|
668
778
|
}
|
|
669
779
|
|
|
670
780
|
/// <reference lib="es2015.core" />
|
|
@@ -682,15 +792,29 @@
|
|
|
682
792
|
function CopyDataBlockBytes(dest, destOffset, src, srcOffset, n) {
|
|
683
793
|
new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
|
|
684
794
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
795
|
+
var TransferArrayBuffer = function (O) {
|
|
796
|
+
if (typeof O.transfer === 'function') {
|
|
797
|
+
TransferArrayBuffer = function (buffer) { return buffer.transfer(); };
|
|
798
|
+
}
|
|
799
|
+
else if (typeof structuredClone === 'function') {
|
|
800
|
+
TransferArrayBuffer = function (buffer) { return structuredClone(buffer, { transfer: [buffer] }); };
|
|
801
|
+
}
|
|
802
|
+
else {
|
|
803
|
+
// Not implemented correctly
|
|
804
|
+
TransferArrayBuffer = function (buffer) { return buffer; };
|
|
805
|
+
}
|
|
806
|
+
return TransferArrayBuffer(O);
|
|
807
|
+
};
|
|
808
|
+
var IsDetachedBuffer = function (O) {
|
|
809
|
+
if (typeof O.detached === 'boolean') {
|
|
810
|
+
IsDetachedBuffer = function (buffer) { return buffer.detached; };
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
// Not implemented correctly
|
|
814
|
+
IsDetachedBuffer = function (buffer) { return buffer.byteLength === 0; };
|
|
815
|
+
}
|
|
816
|
+
return IsDetachedBuffer(O);
|
|
817
|
+
};
|
|
694
818
|
function ArrayBufferSlice(buffer, begin, end) {
|
|
695
819
|
// ArrayBuffer.prototype.slice is not available on IE10
|
|
696
820
|
// https://www.caniuse.com/mdn-javascript_builtins_arraybuffer_slice
|
|
@@ -702,6 +826,79 @@
|
|
|
702
826
|
CopyDataBlockBytes(slice, 0, buffer, begin, length);
|
|
703
827
|
return slice;
|
|
704
828
|
}
|
|
829
|
+
function GetMethod(receiver, prop) {
|
|
830
|
+
var func = receiver[prop];
|
|
831
|
+
if (func === undefined || func === null) {
|
|
832
|
+
return undefined;
|
|
833
|
+
}
|
|
834
|
+
if (typeof func !== 'function') {
|
|
835
|
+
throw new TypeError("".concat(String(prop), " is not a function"));
|
|
836
|
+
}
|
|
837
|
+
return func;
|
|
838
|
+
}
|
|
839
|
+
function CreateAsyncFromSyncIterator(syncIteratorRecord) {
|
|
840
|
+
// Instead of re-implementing CreateAsyncFromSyncIterator and %AsyncFromSyncIteratorPrototype%,
|
|
841
|
+
// we use yield* inside an async generator function to achieve the same result.
|
|
842
|
+
var _a;
|
|
843
|
+
// Wrap the sync iterator inside a sync iterable, so we can use it with yield*.
|
|
844
|
+
var syncIterable = (_a = {},
|
|
845
|
+
_a[SymbolPolyfill.iterator] = function () { return syncIteratorRecord.iterator; },
|
|
846
|
+
_a);
|
|
847
|
+
// Create an async generator function and immediately invoke it.
|
|
848
|
+
var asyncIterator = (function () {
|
|
849
|
+
return __asyncGenerator(this, arguments, function () {
|
|
850
|
+
return __generator(this, function (_a) {
|
|
851
|
+
switch (_a.label) {
|
|
852
|
+
case 0: return [5 /*yield**/, __values(__asyncDelegator(__asyncValues(syncIterable)))];
|
|
853
|
+
case 1: return [4 /*yield*/, __await.apply(void 0, [_a.sent()])];
|
|
854
|
+
case 2: return [4 /*yield*/, __await.apply(void 0, [_a.sent()])];
|
|
855
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
});
|
|
859
|
+
}());
|
|
860
|
+
// Return as an async iterator record.
|
|
861
|
+
var nextMethod = asyncIterator.next;
|
|
862
|
+
return { iterator: asyncIterator, nextMethod: nextMethod, done: false };
|
|
863
|
+
}
|
|
864
|
+
function GetIterator(obj, hint, method) {
|
|
865
|
+
if (hint === void 0) { hint = 'sync'; }
|
|
866
|
+
if (method === undefined) {
|
|
867
|
+
if (hint === 'async') {
|
|
868
|
+
method = GetMethod(obj, SymbolPolyfill.asyncIterator);
|
|
869
|
+
if (method === undefined) {
|
|
870
|
+
var syncMethod = GetMethod(obj, SymbolPolyfill.iterator);
|
|
871
|
+
var syncIteratorRecord = GetIterator(obj, 'sync', syncMethod);
|
|
872
|
+
return CreateAsyncFromSyncIterator(syncIteratorRecord);
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
else {
|
|
876
|
+
method = GetMethod(obj, SymbolPolyfill.iterator);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
if (method === undefined) {
|
|
880
|
+
throw new TypeError('The object is not iterable');
|
|
881
|
+
}
|
|
882
|
+
var iterator = reflectCall(method, obj, []);
|
|
883
|
+
if (!typeIsObject(iterator)) {
|
|
884
|
+
throw new TypeError('The iterator method must return an object');
|
|
885
|
+
}
|
|
886
|
+
var nextMethod = iterator.next;
|
|
887
|
+
return { iterator: iterator, nextMethod: nextMethod, done: false };
|
|
888
|
+
}
|
|
889
|
+
function IteratorNext(iteratorRecord) {
|
|
890
|
+
var result = reflectCall(iteratorRecord.nextMethod, iteratorRecord.iterator, []);
|
|
891
|
+
if (!typeIsObject(result)) {
|
|
892
|
+
throw new TypeError('The iterator.next() method must return an object');
|
|
893
|
+
}
|
|
894
|
+
return result;
|
|
895
|
+
}
|
|
896
|
+
function IteratorComplete(iterResult) {
|
|
897
|
+
return Boolean(iterResult.done);
|
|
898
|
+
}
|
|
899
|
+
function IteratorValue(iterResult) {
|
|
900
|
+
return iterResult.value;
|
|
901
|
+
}
|
|
705
902
|
|
|
706
903
|
function IsNonNegativeNumber(v) {
|
|
707
904
|
if (typeof v !== 'number') {
|
|
@@ -744,6 +941,19 @@
|
|
|
744
941
|
container._queueTotalSize = 0;
|
|
745
942
|
}
|
|
746
943
|
|
|
944
|
+
function isDataViewConstructor(ctor) {
|
|
945
|
+
return ctor === DataView;
|
|
946
|
+
}
|
|
947
|
+
function isDataView(view) {
|
|
948
|
+
return isDataViewConstructor(view.constructor);
|
|
949
|
+
}
|
|
950
|
+
function arrayBufferViewElementSize(ctor) {
|
|
951
|
+
if (isDataViewConstructor(ctor)) {
|
|
952
|
+
return 1;
|
|
953
|
+
}
|
|
954
|
+
return ctor.BYTES_PER_ELEMENT;
|
|
955
|
+
}
|
|
956
|
+
|
|
747
957
|
/**
|
|
748
958
|
* A pull-into request in a {@link ReadableByteStreamController}.
|
|
749
959
|
*
|
|
@@ -775,7 +985,9 @@
|
|
|
775
985
|
if (this._associatedReadableByteStreamController === undefined) {
|
|
776
986
|
throw new TypeError('This BYOB request has been invalidated');
|
|
777
987
|
}
|
|
778
|
-
if (IsDetachedBuffer(this._view.buffer))
|
|
988
|
+
if (IsDetachedBuffer(this._view.buffer)) {
|
|
989
|
+
throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");
|
|
990
|
+
}
|
|
779
991
|
ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
|
|
780
992
|
};
|
|
781
993
|
ReadableStreamBYOBRequest.prototype.respondWithNewView = function (view) {
|
|
@@ -789,7 +1001,9 @@
|
|
|
789
1001
|
if (this._associatedReadableByteStreamController === undefined) {
|
|
790
1002
|
throw new TypeError('This BYOB request has been invalidated');
|
|
791
1003
|
}
|
|
792
|
-
if (IsDetachedBuffer(view.buffer))
|
|
1004
|
+
if (IsDetachedBuffer(view.buffer)) {
|
|
1005
|
+
throw new TypeError('The given view\'s buffer has been detached and so cannot be used as a response');
|
|
1006
|
+
}
|
|
793
1007
|
ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
|
|
794
1008
|
};
|
|
795
1009
|
return ReadableStreamBYOBRequest;
|
|
@@ -799,6 +1013,8 @@
|
|
|
799
1013
|
respondWithNewView: { enumerable: true },
|
|
800
1014
|
view: { enumerable: true }
|
|
801
1015
|
});
|
|
1016
|
+
setFunctionName(ReadableStreamBYOBRequest.prototype.respond, 'respond');
|
|
1017
|
+
setFunctionName(ReadableStreamBYOBRequest.prototype.respondWithNewView, 'respondWithNewView');
|
|
802
1018
|
if (typeof SymbolPolyfill.toStringTag === 'symbol') {
|
|
803
1019
|
Object.defineProperty(ReadableStreamBYOBRequest.prototype, SymbolPolyfill.toStringTag, {
|
|
804
1020
|
value: 'ReadableStreamBYOBRequest',
|
|
@@ -854,7 +1070,7 @@
|
|
|
854
1070
|
}
|
|
855
1071
|
var state = this._controlledReadableByteStream._state;
|
|
856
1072
|
if (state !== 'readable') {
|
|
857
|
-
throw new TypeError("The stream (in "
|
|
1073
|
+
throw new TypeError("The stream (in ".concat(state, " state) is not in the readable state and cannot be closed"));
|
|
858
1074
|
}
|
|
859
1075
|
ReadableByteStreamControllerClose(this);
|
|
860
1076
|
};
|
|
@@ -877,7 +1093,7 @@
|
|
|
877
1093
|
}
|
|
878
1094
|
var state = this._controlledReadableByteStream._state;
|
|
879
1095
|
if (state !== 'readable') {
|
|
880
|
-
throw new TypeError("The stream (in "
|
|
1096
|
+
throw new TypeError("The stream (in ".concat(state, " state) is not in the readable state and cannot be enqueued to"));
|
|
881
1097
|
}
|
|
882
1098
|
ReadableByteStreamControllerEnqueue(this, chunk);
|
|
883
1099
|
};
|
|
@@ -903,11 +1119,7 @@
|
|
|
903
1119
|
ReadableByteStreamController.prototype[PullSteps] = function (readRequest) {
|
|
904
1120
|
var stream = this._controlledReadableByteStream;
|
|
905
1121
|
if (this._queueTotalSize > 0) {
|
|
906
|
-
|
|
907
|
-
this._queueTotalSize -= entry.byteLength;
|
|
908
|
-
ReadableByteStreamControllerHandleQueueDrain(this);
|
|
909
|
-
var view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
|
|
910
|
-
readRequest._chunkSteps(view);
|
|
1122
|
+
ReadableByteStreamControllerFillReadRequestFromQueue(this, readRequest);
|
|
911
1123
|
return;
|
|
912
1124
|
}
|
|
913
1125
|
var autoAllocateChunkSize = this._autoAllocateChunkSize;
|
|
@@ -926,6 +1138,7 @@
|
|
|
926
1138
|
byteOffset: 0,
|
|
927
1139
|
byteLength: autoAllocateChunkSize,
|
|
928
1140
|
bytesFilled: 0,
|
|
1141
|
+
minimumFill: 1,
|
|
929
1142
|
elementSize: 1,
|
|
930
1143
|
viewConstructor: Uint8Array,
|
|
931
1144
|
readerType: 'default'
|
|
@@ -935,6 +1148,15 @@
|
|
|
935
1148
|
ReadableStreamAddReadRequest(stream, readRequest);
|
|
936
1149
|
ReadableByteStreamControllerCallPullIfNeeded(this);
|
|
937
1150
|
};
|
|
1151
|
+
/** @internal */
|
|
1152
|
+
ReadableByteStreamController.prototype[ReleaseSteps] = function () {
|
|
1153
|
+
if (this._pendingPullIntos.length > 0) {
|
|
1154
|
+
var firstPullInto = this._pendingPullIntos.peek();
|
|
1155
|
+
firstPullInto.readerType = 'none';
|
|
1156
|
+
this._pendingPullIntos = new SimpleQueue();
|
|
1157
|
+
this._pendingPullIntos.push(firstPullInto);
|
|
1158
|
+
}
|
|
1159
|
+
};
|
|
938
1160
|
return ReadableByteStreamController;
|
|
939
1161
|
}());
|
|
940
1162
|
Object.defineProperties(ReadableByteStreamController.prototype, {
|
|
@@ -944,6 +1166,9 @@
|
|
|
944
1166
|
byobRequest: { enumerable: true },
|
|
945
1167
|
desiredSize: { enumerable: true }
|
|
946
1168
|
});
|
|
1169
|
+
setFunctionName(ReadableByteStreamController.prototype.close, 'close');
|
|
1170
|
+
setFunctionName(ReadableByteStreamController.prototype.enqueue, 'enqueue');
|
|
1171
|
+
setFunctionName(ReadableByteStreamController.prototype.error, 'error');
|
|
947
1172
|
if (typeof SymbolPolyfill.toStringTag === 'symbol') {
|
|
948
1173
|
Object.defineProperty(ReadableByteStreamController.prototype, SymbolPolyfill.toStringTag, {
|
|
949
1174
|
value: 'ReadableByteStreamController',
|
|
@@ -987,8 +1212,10 @@
|
|
|
987
1212
|
controller._pullAgain = false;
|
|
988
1213
|
ReadableByteStreamControllerCallPullIfNeeded(controller);
|
|
989
1214
|
}
|
|
1215
|
+
return null;
|
|
990
1216
|
}, function (e) {
|
|
991
1217
|
ReadableByteStreamControllerError(controller, e);
|
|
1218
|
+
return null;
|
|
992
1219
|
});
|
|
993
1220
|
}
|
|
994
1221
|
function ReadableByteStreamControllerClearPendingPullIntos(controller) {
|
|
@@ -1017,15 +1244,33 @@
|
|
|
1017
1244
|
controller._queue.push({ buffer: buffer, byteOffset: byteOffset, byteLength: byteLength });
|
|
1018
1245
|
controller._queueTotalSize += byteLength;
|
|
1019
1246
|
}
|
|
1247
|
+
function ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, buffer, byteOffset, byteLength) {
|
|
1248
|
+
var clonedChunk;
|
|
1249
|
+
try {
|
|
1250
|
+
clonedChunk = ArrayBufferSlice(buffer, byteOffset, byteOffset + byteLength);
|
|
1251
|
+
}
|
|
1252
|
+
catch (cloneE) {
|
|
1253
|
+
ReadableByteStreamControllerError(controller, cloneE);
|
|
1254
|
+
throw cloneE;
|
|
1255
|
+
}
|
|
1256
|
+
ReadableByteStreamControllerEnqueueChunkToQueue(controller, clonedChunk, 0, byteLength);
|
|
1257
|
+
}
|
|
1258
|
+
function ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, firstDescriptor) {
|
|
1259
|
+
if (firstDescriptor.bytesFilled > 0) {
|
|
1260
|
+
ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, firstDescriptor.buffer, firstDescriptor.byteOffset, firstDescriptor.bytesFilled);
|
|
1261
|
+
}
|
|
1262
|
+
ReadableByteStreamControllerShiftPendingPullInto(controller);
|
|
1263
|
+
}
|
|
1020
1264
|
function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
|
|
1021
|
-
var elementSize = pullIntoDescriptor.elementSize;
|
|
1022
|
-
var currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
|
|
1023
1265
|
var maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
|
|
1024
1266
|
var maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
|
|
1025
|
-
var maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
|
|
1026
1267
|
var totalBytesToCopyRemaining = maxBytesToCopy;
|
|
1027
1268
|
var ready = false;
|
|
1028
|
-
|
|
1269
|
+
var remainderBytes = maxBytesFilled % pullIntoDescriptor.elementSize;
|
|
1270
|
+
var maxAlignedBytes = maxBytesFilled - remainderBytes;
|
|
1271
|
+
// A descriptor for a read() request that is not yet filled up to its minimum length will stay at the head
|
|
1272
|
+
// of the queue, so the underlying source can keep filling it.
|
|
1273
|
+
if (maxAlignedBytes >= pullIntoDescriptor.minimumFill) {
|
|
1029
1274
|
totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
|
|
1030
1275
|
ready = true;
|
|
1031
1276
|
}
|
|
@@ -1080,25 +1325,37 @@
|
|
|
1080
1325
|
}
|
|
1081
1326
|
}
|
|
1082
1327
|
}
|
|
1083
|
-
function
|
|
1084
|
-
var
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1328
|
+
function ReadableByteStreamControllerProcessReadRequestsUsingQueue(controller) {
|
|
1329
|
+
var reader = controller._controlledReadableByteStream._reader;
|
|
1330
|
+
while (reader._readRequests.length > 0) {
|
|
1331
|
+
if (controller._queueTotalSize === 0) {
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
var readRequest = reader._readRequests.shift();
|
|
1335
|
+
ReadableByteStreamControllerFillReadRequestFromQueue(controller, readRequest);
|
|
1088
1336
|
}
|
|
1337
|
+
}
|
|
1338
|
+
function ReadableByteStreamControllerPullInto(controller, view, min, readIntoRequest) {
|
|
1339
|
+
var stream = controller._controlledReadableByteStream;
|
|
1089
1340
|
var ctor = view.constructor;
|
|
1090
|
-
|
|
1091
|
-
var
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1341
|
+
var elementSize = arrayBufferViewElementSize(ctor);
|
|
1342
|
+
var byteOffset = view.byteOffset, byteLength = view.byteLength;
|
|
1343
|
+
var minimumFill = min * elementSize;
|
|
1344
|
+
var buffer;
|
|
1345
|
+
try {
|
|
1346
|
+
buffer = TransferArrayBuffer(view.buffer);
|
|
1347
|
+
}
|
|
1348
|
+
catch (e) {
|
|
1349
|
+
readIntoRequest._errorSteps(e);
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1096
1352
|
var pullIntoDescriptor = {
|
|
1097
1353
|
buffer: buffer,
|
|
1098
1354
|
bufferByteLength: buffer.byteLength,
|
|
1099
|
-
byteOffset:
|
|
1100
|
-
byteLength:
|
|
1355
|
+
byteOffset: byteOffset,
|
|
1356
|
+
byteLength: byteLength,
|
|
1101
1357
|
bytesFilled: 0,
|
|
1358
|
+
minimumFill: minimumFill,
|
|
1102
1359
|
elementSize: elementSize,
|
|
1103
1360
|
viewConstructor: ctor,
|
|
1104
1361
|
readerType: 'byob'
|
|
@@ -1135,6 +1392,9 @@
|
|
|
1135
1392
|
ReadableByteStreamControllerCallPullIfNeeded(controller);
|
|
1136
1393
|
}
|
|
1137
1394
|
function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
|
|
1395
|
+
if (firstDescriptor.readerType === 'none') {
|
|
1396
|
+
ReadableByteStreamControllerShiftPendingPullInto(controller);
|
|
1397
|
+
}
|
|
1138
1398
|
var stream = controller._controlledReadableByteStream;
|
|
1139
1399
|
if (ReadableStreamHasBYOBReader(stream)) {
|
|
1140
1400
|
while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
|
|
@@ -1145,15 +1405,21 @@
|
|
|
1145
1405
|
}
|
|
1146
1406
|
function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
|
|
1147
1407
|
ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
|
|
1148
|
-
if (pullIntoDescriptor.
|
|
1408
|
+
if (pullIntoDescriptor.readerType === 'none') {
|
|
1409
|
+
ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, pullIntoDescriptor);
|
|
1410
|
+
ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.minimumFill) {
|
|
1414
|
+
// A descriptor for a read() request that is not yet filled up to its minimum length will stay at the head
|
|
1415
|
+
// of the queue, so the underlying source can keep filling it.
|
|
1149
1416
|
return;
|
|
1150
1417
|
}
|
|
1151
1418
|
ReadableByteStreamControllerShiftPendingPullInto(controller);
|
|
1152
1419
|
var remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
|
|
1153
1420
|
if (remainderSize > 0) {
|
|
1154
1421
|
var end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
|
|
1155
|
-
|
|
1156
|
-
ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
|
|
1422
|
+
ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, pullIntoDescriptor.buffer, end - remainderSize, remainderSize);
|
|
1157
1423
|
}
|
|
1158
1424
|
pullIntoDescriptor.bytesFilled -= remainderSize;
|
|
1159
1425
|
ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor);
|
|
@@ -1164,7 +1430,7 @@
|
|
|
1164
1430
|
ReadableByteStreamControllerInvalidateBYOBRequest(controller);
|
|
1165
1431
|
var state = controller._controlledReadableByteStream._state;
|
|
1166
1432
|
if (state === 'closed') {
|
|
1167
|
-
ReadableByteStreamControllerRespondInClosedState(controller);
|
|
1433
|
+
ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
|
|
1168
1434
|
}
|
|
1169
1435
|
else {
|
|
1170
1436
|
ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
|
|
@@ -1214,7 +1480,7 @@
|
|
|
1214
1480
|
}
|
|
1215
1481
|
if (controller._pendingPullIntos.length > 0) {
|
|
1216
1482
|
var firstPendingPullInto = controller._pendingPullIntos.peek();
|
|
1217
|
-
if (firstPendingPullInto.bytesFilled
|
|
1483
|
+
if (firstPendingPullInto.bytesFilled % firstPendingPullInto.elementSize !== 0) {
|
|
1218
1484
|
var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
|
|
1219
1485
|
ReadableByteStreamControllerError(controller, e);
|
|
1220
1486
|
throw e;
|
|
@@ -1228,17 +1494,24 @@
|
|
|
1228
1494
|
if (controller._closeRequested || stream._state !== 'readable') {
|
|
1229
1495
|
return;
|
|
1230
1496
|
}
|
|
1231
|
-
var buffer = chunk.buffer;
|
|
1232
|
-
|
|
1233
|
-
|
|
1497
|
+
var buffer = chunk.buffer, byteOffset = chunk.byteOffset, byteLength = chunk.byteLength;
|
|
1498
|
+
if (IsDetachedBuffer(buffer)) {
|
|
1499
|
+
throw new TypeError('chunk\'s buffer is detached and so cannot be enqueued');
|
|
1500
|
+
}
|
|
1234
1501
|
var transferredBuffer = TransferArrayBuffer(buffer);
|
|
1235
1502
|
if (controller._pendingPullIntos.length > 0) {
|
|
1236
1503
|
var firstPendingPullInto = controller._pendingPullIntos.peek();
|
|
1237
|
-
if (IsDetachedBuffer(firstPendingPullInto.buffer))
|
|
1504
|
+
if (IsDetachedBuffer(firstPendingPullInto.buffer)) {
|
|
1505
|
+
throw new TypeError('The BYOB request\'s buffer has been detached and so cannot be filled with an enqueued chunk');
|
|
1506
|
+
}
|
|
1507
|
+
ReadableByteStreamControllerInvalidateBYOBRequest(controller);
|
|
1238
1508
|
firstPendingPullInto.buffer = TransferArrayBuffer(firstPendingPullInto.buffer);
|
|
1509
|
+
if (firstPendingPullInto.readerType === 'none') {
|
|
1510
|
+
ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, firstPendingPullInto);
|
|
1511
|
+
}
|
|
1239
1512
|
}
|
|
1240
|
-
ReadableByteStreamControllerInvalidateBYOBRequest(controller);
|
|
1241
1513
|
if (ReadableStreamHasDefaultReader(stream)) {
|
|
1514
|
+
ReadableByteStreamControllerProcessReadRequestsUsingQueue(controller);
|
|
1242
1515
|
if (ReadableStreamGetNumReadRequests(stream) === 0) {
|
|
1243
1516
|
ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
|
|
1244
1517
|
}
|
|
@@ -1270,6 +1543,13 @@
|
|
|
1270
1543
|
ReadableByteStreamControllerClearAlgorithms(controller);
|
|
1271
1544
|
ReadableStreamError(stream, e);
|
|
1272
1545
|
}
|
|
1546
|
+
function ReadableByteStreamControllerFillReadRequestFromQueue(controller, readRequest) {
|
|
1547
|
+
var entry = controller._queue.shift();
|
|
1548
|
+
controller._queueTotalSize -= entry.byteLength;
|
|
1549
|
+
ReadableByteStreamControllerHandleQueueDrain(controller);
|
|
1550
|
+
var view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
|
|
1551
|
+
readRequest._chunkSteps(view);
|
|
1552
|
+
}
|
|
1273
1553
|
function ReadableByteStreamControllerGetBYOBRequest(controller) {
|
|
1274
1554
|
if (controller._byobRequest === null && controller._pendingPullIntos.length > 0) {
|
|
1275
1555
|
var firstDescriptor = controller._pendingPullIntos.peek();
|
|
@@ -1355,24 +1635,35 @@
|
|
|
1355
1635
|
uponPromise(promiseResolvedWith(startResult), function () {
|
|
1356
1636
|
controller._started = true;
|
|
1357
1637
|
ReadableByteStreamControllerCallPullIfNeeded(controller);
|
|
1638
|
+
return null;
|
|
1358
1639
|
}, function (r) {
|
|
1359
1640
|
ReadableByteStreamControllerError(controller, r);
|
|
1641
|
+
return null;
|
|
1360
1642
|
});
|
|
1361
1643
|
}
|
|
1362
1644
|
function SetUpReadableByteStreamControllerFromUnderlyingSource(stream, underlyingByteSource, highWaterMark) {
|
|
1363
1645
|
var controller = Object.create(ReadableByteStreamController.prototype);
|
|
1364
|
-
var startAlgorithm
|
|
1365
|
-
var pullAlgorithm
|
|
1366
|
-
var cancelAlgorithm
|
|
1646
|
+
var startAlgorithm;
|
|
1647
|
+
var pullAlgorithm;
|
|
1648
|
+
var cancelAlgorithm;
|
|
1367
1649
|
if (underlyingByteSource.start !== undefined) {
|
|
1368
1650
|
startAlgorithm = function () { return underlyingByteSource.start(controller); };
|
|
1369
1651
|
}
|
|
1652
|
+
else {
|
|
1653
|
+
startAlgorithm = function () { return undefined; };
|
|
1654
|
+
}
|
|
1370
1655
|
if (underlyingByteSource.pull !== undefined) {
|
|
1371
1656
|
pullAlgorithm = function () { return underlyingByteSource.pull(controller); };
|
|
1372
1657
|
}
|
|
1658
|
+
else {
|
|
1659
|
+
pullAlgorithm = function () { return promiseResolvedWith(undefined); };
|
|
1660
|
+
}
|
|
1373
1661
|
if (underlyingByteSource.cancel !== undefined) {
|
|
1374
1662
|
cancelAlgorithm = function (reason) { return underlyingByteSource.cancel(reason); };
|
|
1375
1663
|
}
|
|
1664
|
+
else {
|
|
1665
|
+
cancelAlgorithm = function () { return promiseResolvedWith(undefined); };
|
|
1666
|
+
}
|
|
1376
1667
|
var autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
|
|
1377
1668
|
if (autoAllocateChunkSize === 0) {
|
|
1378
1669
|
throw new TypeError('autoAllocateChunkSize must be greater than 0');
|
|
@@ -1385,11 +1676,34 @@
|
|
|
1385
1676
|
}
|
|
1386
1677
|
// Helper functions for the ReadableStreamBYOBRequest.
|
|
1387
1678
|
function byobRequestBrandCheckException(name) {
|
|
1388
|
-
return new TypeError("ReadableStreamBYOBRequest.prototype."
|
|
1679
|
+
return new TypeError("ReadableStreamBYOBRequest.prototype.".concat(name, " can only be used on a ReadableStreamBYOBRequest"));
|
|
1389
1680
|
}
|
|
1390
1681
|
// Helper functions for the ReadableByteStreamController.
|
|
1391
1682
|
function byteStreamControllerBrandCheckException(name) {
|
|
1392
|
-
return new TypeError("ReadableByteStreamController.prototype."
|
|
1683
|
+
return new TypeError("ReadableByteStreamController.prototype.".concat(name, " can only be used on a ReadableByteStreamController"));
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
function convertReaderOptions(options, context) {
|
|
1687
|
+
assertDictionary(options, context);
|
|
1688
|
+
var mode = options === null || options === void 0 ? void 0 : options.mode;
|
|
1689
|
+
return {
|
|
1690
|
+
mode: mode === undefined ? undefined : convertReadableStreamReaderMode(mode, "".concat(context, " has member 'mode' that"))
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
function convertReadableStreamReaderMode(mode, context) {
|
|
1694
|
+
mode = "".concat(mode);
|
|
1695
|
+
if (mode !== 'byob') {
|
|
1696
|
+
throw new TypeError("".concat(context, " '").concat(mode, "' is not a valid enumeration value for ReadableStreamReaderMode"));
|
|
1697
|
+
}
|
|
1698
|
+
return mode;
|
|
1699
|
+
}
|
|
1700
|
+
function convertByobReadOptions(options, context) {
|
|
1701
|
+
var _a;
|
|
1702
|
+
assertDictionary(options, context);
|
|
1703
|
+
var min = (_a = options === null || options === void 0 ? void 0 : options.min) !== null && _a !== void 0 ? _a : 1;
|
|
1704
|
+
return {
|
|
1705
|
+
min: convertUnsignedLongLongWithEnforceRange(min, "".concat(context, " has member 'min' that"))
|
|
1706
|
+
};
|
|
1393
1707
|
}
|
|
1394
1708
|
|
|
1395
1709
|
// Abstract operations for the ReadableStream.
|
|
@@ -1469,12 +1783,8 @@
|
|
|
1469
1783
|
}
|
|
1470
1784
|
return ReadableStreamReaderGenericCancel(this, reason);
|
|
1471
1785
|
};
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
*
|
|
1475
|
-
* If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source.
|
|
1476
|
-
*/
|
|
1477
|
-
ReadableStreamBYOBReader.prototype.read = function (view) {
|
|
1786
|
+
ReadableStreamBYOBReader.prototype.read = function (view, rawOptions) {
|
|
1787
|
+
if (rawOptions === void 0) { rawOptions = {}; }
|
|
1478
1788
|
if (!IsReadableStreamBYOBReader(this)) {
|
|
1479
1789
|
return promiseRejectedWith(byobReaderBrandCheckException('read'));
|
|
1480
1790
|
}
|
|
@@ -1487,7 +1797,28 @@
|
|
|
1487
1797
|
if (view.buffer.byteLength === 0) {
|
|
1488
1798
|
return promiseRejectedWith(new TypeError("view's buffer must have non-zero byteLength"));
|
|
1489
1799
|
}
|
|
1490
|
-
if (IsDetachedBuffer(view.buffer))
|
|
1800
|
+
if (IsDetachedBuffer(view.buffer)) {
|
|
1801
|
+
return promiseRejectedWith(new TypeError('view\'s buffer has been detached'));
|
|
1802
|
+
}
|
|
1803
|
+
var options;
|
|
1804
|
+
try {
|
|
1805
|
+
options = convertByobReadOptions(rawOptions, 'options');
|
|
1806
|
+
}
|
|
1807
|
+
catch (e) {
|
|
1808
|
+
return promiseRejectedWith(e);
|
|
1809
|
+
}
|
|
1810
|
+
var min = options.min;
|
|
1811
|
+
if (min === 0) {
|
|
1812
|
+
return promiseRejectedWith(new TypeError('options.min must be greater than 0'));
|
|
1813
|
+
}
|
|
1814
|
+
if (!isDataView(view)) {
|
|
1815
|
+
if (min > view.length) {
|
|
1816
|
+
return promiseRejectedWith(new RangeError('options.min must be less than or equal to view\'s length'));
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
else if (min > view.byteLength) {
|
|
1820
|
+
return promiseRejectedWith(new RangeError('options.min must be less than or equal to view\'s byteLength'));
|
|
1821
|
+
}
|
|
1491
1822
|
if (this._ownerReadableStream === undefined) {
|
|
1492
1823
|
return promiseRejectedWith(readerLockException('read from'));
|
|
1493
1824
|
}
|
|
@@ -1502,7 +1833,7 @@
|
|
|
1502
1833
|
_closeSteps: function (chunk) { return resolvePromise({ value: chunk, done: true }); },
|
|
1503
1834
|
_errorSteps: function (e) { return rejectPromise(e); }
|
|
1504
1835
|
};
|
|
1505
|
-
ReadableStreamBYOBReaderRead(this, view, readIntoRequest);
|
|
1836
|
+
ReadableStreamBYOBReaderRead(this, view, min, readIntoRequest);
|
|
1506
1837
|
return promise;
|
|
1507
1838
|
};
|
|
1508
1839
|
/**
|
|
@@ -1521,10 +1852,7 @@
|
|
|
1521
1852
|
if (this._ownerReadableStream === undefined) {
|
|
1522
1853
|
return;
|
|
1523
1854
|
}
|
|
1524
|
-
|
|
1525
|
-
throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
|
|
1526
|
-
}
|
|
1527
|
-
ReadableStreamReaderGenericRelease(this);
|
|
1855
|
+
ReadableStreamBYOBReaderRelease(this);
|
|
1528
1856
|
};
|
|
1529
1857
|
return ReadableStreamBYOBReader;
|
|
1530
1858
|
}());
|
|
@@ -1534,6 +1862,9 @@
|
|
|
1534
1862
|
releaseLock: { enumerable: true },
|
|
1535
1863
|
closed: { enumerable: true }
|
|
1536
1864
|
});
|
|
1865
|
+
setFunctionName(ReadableStreamBYOBReader.prototype.cancel, 'cancel');
|
|
1866
|
+
setFunctionName(ReadableStreamBYOBReader.prototype.read, 'read');
|
|
1867
|
+
setFunctionName(ReadableStreamBYOBReader.prototype.releaseLock, 'releaseLock');
|
|
1537
1868
|
if (typeof SymbolPolyfill.toStringTag === 'symbol') {
|
|
1538
1869
|
Object.defineProperty(ReadableStreamBYOBReader.prototype, SymbolPolyfill.toStringTag, {
|
|
1539
1870
|
value: 'ReadableStreamBYOBReader',
|
|
@@ -1550,19 +1881,31 @@
|
|
|
1550
1881
|
}
|
|
1551
1882
|
return x instanceof ReadableStreamBYOBReader;
|
|
1552
1883
|
}
|
|
1553
|
-
function ReadableStreamBYOBReaderRead(reader, view, readIntoRequest) {
|
|
1884
|
+
function ReadableStreamBYOBReaderRead(reader, view, min, readIntoRequest) {
|
|
1554
1885
|
var stream = reader._ownerReadableStream;
|
|
1555
1886
|
stream._disturbed = true;
|
|
1556
1887
|
if (stream._state === 'errored') {
|
|
1557
1888
|
readIntoRequest._errorSteps(stream._storedError);
|
|
1558
1889
|
}
|
|
1559
1890
|
else {
|
|
1560
|
-
ReadableByteStreamControllerPullInto(stream._readableStreamController, view, readIntoRequest);
|
|
1891
|
+
ReadableByteStreamControllerPullInto(stream._readableStreamController, view, min, readIntoRequest);
|
|
1561
1892
|
}
|
|
1562
1893
|
}
|
|
1894
|
+
function ReadableStreamBYOBReaderRelease(reader) {
|
|
1895
|
+
ReadableStreamReaderGenericRelease(reader);
|
|
1896
|
+
var e = new TypeError('Reader was released');
|
|
1897
|
+
ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e);
|
|
1898
|
+
}
|
|
1899
|
+
function ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e) {
|
|
1900
|
+
var readIntoRequests = reader._readIntoRequests;
|
|
1901
|
+
reader._readIntoRequests = new SimpleQueue();
|
|
1902
|
+
readIntoRequests.forEach(function (readIntoRequest) {
|
|
1903
|
+
readIntoRequest._errorSteps(e);
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1563
1906
|
// Helper functions for the ReadableStreamBYOBReader.
|
|
1564
1907
|
function byobReaderBrandCheckException(name) {
|
|
1565
|
-
return new TypeError("ReadableStreamBYOBReader.prototype."
|
|
1908
|
+
return new TypeError("ReadableStreamBYOBReader.prototype.".concat(name, " can only be used on a ReadableStreamBYOBReader"));
|
|
1566
1909
|
}
|
|
1567
1910
|
|
|
1568
1911
|
function ExtractHighWaterMark(strategy, defaultHWM) {
|
|
@@ -1589,7 +1932,7 @@
|
|
|
1589
1932
|
var size = init === null || init === void 0 ? void 0 : init.size;
|
|
1590
1933
|
return {
|
|
1591
1934
|
highWaterMark: highWaterMark === undefined ? undefined : convertUnrestrictedDouble(highWaterMark),
|
|
1592
|
-
size: size === undefined ? undefined : convertQueuingStrategySize(size, context
|
|
1935
|
+
size: size === undefined ? undefined : convertQueuingStrategySize(size, "".concat(context, " has member 'size' that"))
|
|
1593
1936
|
};
|
|
1594
1937
|
}
|
|
1595
1938
|
function convertQueuingStrategySize(fn, context) {
|
|
@@ -1607,16 +1950,16 @@
|
|
|
1607
1950
|
return {
|
|
1608
1951
|
abort: abort === undefined ?
|
|
1609
1952
|
undefined :
|
|
1610
|
-
convertUnderlyingSinkAbortCallback(abort, original, context
|
|
1953
|
+
convertUnderlyingSinkAbortCallback(abort, original, "".concat(context, " has member 'abort' that")),
|
|
1611
1954
|
close: close === undefined ?
|
|
1612
1955
|
undefined :
|
|
1613
|
-
convertUnderlyingSinkCloseCallback(close, original, context
|
|
1956
|
+
convertUnderlyingSinkCloseCallback(close, original, "".concat(context, " has member 'close' that")),
|
|
1614
1957
|
start: start === undefined ?
|
|
1615
1958
|
undefined :
|
|
1616
|
-
convertUnderlyingSinkStartCallback(start, original, context
|
|
1959
|
+
convertUnderlyingSinkStartCallback(start, original, "".concat(context, " has member 'start' that")),
|
|
1617
1960
|
write: write === undefined ?
|
|
1618
1961
|
undefined :
|
|
1619
|
-
convertUnderlyingSinkWriteCallback(write, original, context
|
|
1962
|
+
convertUnderlyingSinkWriteCallback(write, original, "".concat(context, " has member 'write' that")),
|
|
1620
1963
|
type: type
|
|
1621
1964
|
};
|
|
1622
1965
|
}
|
|
@@ -1639,7 +1982,7 @@
|
|
|
1639
1982
|
|
|
1640
1983
|
function assertWritableStream(x, context) {
|
|
1641
1984
|
if (!IsWritableStream(x)) {
|
|
1642
|
-
throw new TypeError(context
|
|
1985
|
+
throw new TypeError("".concat(context, " is not a WritableStream."));
|
|
1643
1986
|
}
|
|
1644
1987
|
}
|
|
1645
1988
|
|
|
@@ -1768,6 +2111,9 @@
|
|
|
1768
2111
|
getWriter: { enumerable: true },
|
|
1769
2112
|
locked: { enumerable: true }
|
|
1770
2113
|
});
|
|
2114
|
+
setFunctionName(WritableStream.prototype.abort, 'abort');
|
|
2115
|
+
setFunctionName(WritableStream.prototype.close, 'close');
|
|
2116
|
+
setFunctionName(WritableStream.prototype.getWriter, 'getWriter');
|
|
1771
2117
|
if (typeof SymbolPolyfill.toStringTag === 'symbol') {
|
|
1772
2118
|
Object.defineProperty(WritableStream.prototype, SymbolPolyfill.toStringTag, {
|
|
1773
2119
|
value: 'WritableStream',
|
|
@@ -1835,7 +2181,7 @@
|
|
|
1835
2181
|
return promiseResolvedWith(undefined);
|
|
1836
2182
|
}
|
|
1837
2183
|
stream._writableStreamController._abortReason = reason;
|
|
1838
|
-
(_a = stream._writableStreamController._abortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
2184
|
+
(_a = stream._writableStreamController._abortController) === null || _a === void 0 ? void 0 : _a.abort(reason);
|
|
1839
2185
|
// TypeScript narrows the type of `stream._state` down to 'writable' | 'erroring',
|
|
1840
2186
|
// but it doesn't know that signaling abort runs author code that might have changed the state.
|
|
1841
2187
|
// Widen the type again by casting to WritableStreamState.
|
|
@@ -1870,7 +2216,7 @@
|
|
|
1870
2216
|
function WritableStreamClose(stream) {
|
|
1871
2217
|
var state = stream._state;
|
|
1872
2218
|
if (state === 'closed' || state === 'errored') {
|
|
1873
|
-
return promiseRejectedWith(new TypeError("The stream (in "
|
|
2219
|
+
return promiseRejectedWith(new TypeError("The stream (in ".concat(state, " state) is not in the writable state and cannot be closed")));
|
|
1874
2220
|
}
|
|
1875
2221
|
var promise = newPromise(function (resolve, reject) {
|
|
1876
2222
|
var closeRequest = {
|
|
@@ -1940,9 +2286,11 @@
|
|
|
1940
2286
|
uponPromise(promise, function () {
|
|
1941
2287
|
abortRequest._resolve();
|
|
1942
2288
|
WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
|
|
2289
|
+
return null;
|
|
1943
2290
|
}, function (reason) {
|
|
1944
2291
|
abortRequest._reject(reason);
|
|
1945
2292
|
WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
|
|
2293
|
+
return null;
|
|
1946
2294
|
});
|
|
1947
2295
|
}
|
|
1948
2296
|
function WritableStreamFinishInFlightWrite(stream) {
|
|
@@ -2185,6 +2533,10 @@
|
|
|
2185
2533
|
desiredSize: { enumerable: true },
|
|
2186
2534
|
ready: { enumerable: true }
|
|
2187
2535
|
});
|
|
2536
|
+
setFunctionName(WritableStreamDefaultWriter.prototype.abort, 'abort');
|
|
2537
|
+
setFunctionName(WritableStreamDefaultWriter.prototype.close, 'close');
|
|
2538
|
+
setFunctionName(WritableStreamDefaultWriter.prototype.releaseLock, 'releaseLock');
|
|
2539
|
+
setFunctionName(WritableStreamDefaultWriter.prototype.write, 'write');
|
|
2188
2540
|
if (typeof SymbolPolyfill.toStringTag === 'symbol') {
|
|
2189
2541
|
Object.defineProperty(WritableStreamDefaultWriter.prototype, SymbolPolyfill.toStringTag, {
|
|
2190
2542
|
value: 'WritableStreamDefaultWriter',
|
|
@@ -2400,29 +2752,43 @@
|
|
|
2400
2752
|
uponPromise(startPromise, function () {
|
|
2401
2753
|
controller._started = true;
|
|
2402
2754
|
WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
|
|
2755
|
+
return null;
|
|
2403
2756
|
}, function (r) {
|
|
2404
2757
|
controller._started = true;
|
|
2405
2758
|
WritableStreamDealWithRejection(stream, r);
|
|
2759
|
+
return null;
|
|
2406
2760
|
});
|
|
2407
2761
|
}
|
|
2408
2762
|
function SetUpWritableStreamDefaultControllerFromUnderlyingSink(stream, underlyingSink, highWaterMark, sizeAlgorithm) {
|
|
2409
2763
|
var controller = Object.create(WritableStreamDefaultController.prototype);
|
|
2410
|
-
var startAlgorithm
|
|
2411
|
-
var writeAlgorithm
|
|
2412
|
-
var closeAlgorithm
|
|
2413
|
-
var abortAlgorithm
|
|
2764
|
+
var startAlgorithm;
|
|
2765
|
+
var writeAlgorithm;
|
|
2766
|
+
var closeAlgorithm;
|
|
2767
|
+
var abortAlgorithm;
|
|
2414
2768
|
if (underlyingSink.start !== undefined) {
|
|
2415
2769
|
startAlgorithm = function () { return underlyingSink.start(controller); };
|
|
2416
2770
|
}
|
|
2771
|
+
else {
|
|
2772
|
+
startAlgorithm = function () { return undefined; };
|
|
2773
|
+
}
|
|
2417
2774
|
if (underlyingSink.write !== undefined) {
|
|
2418
2775
|
writeAlgorithm = function (chunk) { return underlyingSink.write(chunk, controller); };
|
|
2419
2776
|
}
|
|
2777
|
+
else {
|
|
2778
|
+
writeAlgorithm = function () { return promiseResolvedWith(undefined); };
|
|
2779
|
+
}
|
|
2420
2780
|
if (underlyingSink.close !== undefined) {
|
|
2421
2781
|
closeAlgorithm = function () { return underlyingSink.close(); };
|
|
2422
2782
|
}
|
|
2783
|
+
else {
|
|
2784
|
+
closeAlgorithm = function () { return promiseResolvedWith(undefined); };
|
|
2785
|
+
}
|
|
2423
2786
|
if (underlyingSink.abort !== undefined) {
|
|
2424
2787
|
abortAlgorithm = function (reason) { return underlyingSink.abort(reason); };
|
|
2425
2788
|
}
|
|
2789
|
+
else {
|
|
2790
|
+
abortAlgorithm = function () { return promiseResolvedWith(undefined); };
|
|
2791
|
+
}
|
|
2426
2792
|
SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
|
|
2427
2793
|
}
|
|
2428
2794
|
// ClearAlgorithms may be called twice. Erroring the same stream in multiple ways will often result in redundant calls.
|
|
@@ -2501,8 +2867,10 @@
|
|
|
2501
2867
|
WritableStreamDefaultControllerClearAlgorithms(controller);
|
|
2502
2868
|
uponPromise(sinkClosePromise, function () {
|
|
2503
2869
|
WritableStreamFinishInFlightClose(stream);
|
|
2870
|
+
return null;
|
|
2504
2871
|
}, function (reason) {
|
|
2505
2872
|
WritableStreamFinishInFlightCloseWithError(stream, reason);
|
|
2873
|
+
return null;
|
|
2506
2874
|
});
|
|
2507
2875
|
}
|
|
2508
2876
|
function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
|
|
@@ -2518,11 +2886,13 @@
|
|
|
2518
2886
|
WritableStreamUpdateBackpressure(stream, backpressure);
|
|
2519
2887
|
}
|
|
2520
2888
|
WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
|
|
2889
|
+
return null;
|
|
2521
2890
|
}, function (reason) {
|
|
2522
2891
|
if (stream._state === 'writable') {
|
|
2523
2892
|
WritableStreamDefaultControllerClearAlgorithms(controller);
|
|
2524
2893
|
}
|
|
2525
2894
|
WritableStreamFinishInFlightWriteWithError(stream, reason);
|
|
2895
|
+
return null;
|
|
2526
2896
|
});
|
|
2527
2897
|
}
|
|
2528
2898
|
function WritableStreamDefaultControllerGetBackpressure(controller) {
|
|
@@ -2537,15 +2907,15 @@
|
|
|
2537
2907
|
}
|
|
2538
2908
|
// Helper functions for the WritableStream.
|
|
2539
2909
|
function streamBrandCheckException$2(name) {
|
|
2540
|
-
return new TypeError("WritableStream.prototype."
|
|
2910
|
+
return new TypeError("WritableStream.prototype.".concat(name, " can only be used on a WritableStream"));
|
|
2541
2911
|
}
|
|
2542
2912
|
// Helper functions for the WritableStreamDefaultController.
|
|
2543
2913
|
function defaultControllerBrandCheckException$2(name) {
|
|
2544
|
-
return new TypeError("WritableStreamDefaultController.prototype."
|
|
2914
|
+
return new TypeError("WritableStreamDefaultController.prototype.".concat(name, " can only be used on a WritableStreamDefaultController"));
|
|
2545
2915
|
}
|
|
2546
2916
|
// Helper functions for the WritableStreamDefaultWriter.
|
|
2547
2917
|
function defaultWriterBrandCheckException(name) {
|
|
2548
|
-
return new TypeError("WritableStreamDefaultWriter.prototype."
|
|
2918
|
+
return new TypeError("WritableStreamDefaultWriter.prototype.".concat(name, " can only be used on a WritableStreamDefaultWriter"));
|
|
2549
2919
|
}
|
|
2550
2920
|
function defaultWriterLockException(name) {
|
|
2551
2921
|
return new TypeError('Cannot ' + name + ' a stream using a released writer');
|
|
@@ -2629,13 +2999,28 @@
|
|
|
2629
2999
|
}
|
|
2630
3000
|
|
|
2631
3001
|
/// <reference lib="dom" />
|
|
2632
|
-
|
|
3002
|
+
function getGlobals() {
|
|
3003
|
+
if (typeof globalThis !== 'undefined') {
|
|
3004
|
+
return globalThis;
|
|
3005
|
+
}
|
|
3006
|
+
else if (typeof self !== 'undefined') {
|
|
3007
|
+
return self;
|
|
3008
|
+
}
|
|
3009
|
+
else if (typeof global !== 'undefined') {
|
|
3010
|
+
return global;
|
|
3011
|
+
}
|
|
3012
|
+
return undefined;
|
|
3013
|
+
}
|
|
3014
|
+
var globals = getGlobals();
|
|
2633
3015
|
|
|
2634
3016
|
/// <reference types="node" />
|
|
2635
3017
|
function isDOMExceptionConstructor(ctor) {
|
|
2636
3018
|
if (!(typeof ctor === 'function' || typeof ctor === 'object')) {
|
|
2637
3019
|
return false;
|
|
2638
3020
|
}
|
|
3021
|
+
if (ctor.name !== 'DOMException') {
|
|
3022
|
+
return false;
|
|
3023
|
+
}
|
|
2639
3024
|
try {
|
|
2640
3025
|
new ctor();
|
|
2641
3026
|
return true;
|
|
@@ -2644,8 +3029,21 @@
|
|
|
2644
3029
|
return false;
|
|
2645
3030
|
}
|
|
2646
3031
|
}
|
|
2647
|
-
|
|
2648
|
-
|
|
3032
|
+
/**
|
|
3033
|
+
* Support:
|
|
3034
|
+
* - Web browsers
|
|
3035
|
+
* - Node 18 and higher (https://github.com/nodejs/node/commit/e4b1fb5e6422c1ff151234bb9de792d45dd88d87)
|
|
3036
|
+
*/
|
|
3037
|
+
function getFromGlobal() {
|
|
3038
|
+
var ctor = globals === null || globals === void 0 ? void 0 : globals.DOMException;
|
|
3039
|
+
return isDOMExceptionConstructor(ctor) ? ctor : undefined;
|
|
3040
|
+
}
|
|
3041
|
+
/**
|
|
3042
|
+
* Support:
|
|
3043
|
+
* - All platforms
|
|
3044
|
+
*/
|
|
3045
|
+
function createPolyfill() {
|
|
3046
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
2649
3047
|
var ctor = function DOMException(message, name) {
|
|
2650
3048
|
this.message = message || '';
|
|
2651
3049
|
this.name = name || 'Error';
|
|
@@ -2653,12 +3051,13 @@
|
|
|
2653
3051
|
Error.captureStackTrace(this, this.constructor);
|
|
2654
3052
|
}
|
|
2655
3053
|
};
|
|
3054
|
+
setFunctionName(ctor, 'DOMException');
|
|
2656
3055
|
ctor.prototype = Object.create(Error.prototype);
|
|
2657
3056
|
Object.defineProperty(ctor.prototype, 'constructor', { value: ctor, writable: true, configurable: true });
|
|
2658
3057
|
return ctor;
|
|
2659
3058
|
}
|
|
2660
|
-
// eslint-disable-next-line no-redeclare
|
|
2661
|
-
var DOMException
|
|
3059
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
3060
|
+
var DOMException = getFromGlobal() || createPolyfill();
|
|
2662
3061
|
|
|
2663
3062
|
function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
|
|
2664
3063
|
var reader = AcquireReadableStreamDefaultReader(source);
|
|
@@ -2671,7 +3070,7 @@
|
|
|
2671
3070
|
var abortAlgorithm;
|
|
2672
3071
|
if (signal !== undefined) {
|
|
2673
3072
|
abortAlgorithm = function () {
|
|
2674
|
-
var error = new DOMException
|
|
3073
|
+
var error = signal.reason !== undefined ? signal.reason : new DOMException('Aborted', 'AbortError');
|
|
2675
3074
|
var actions = [];
|
|
2676
3075
|
if (!preventAbort) {
|
|
2677
3076
|
actions.push(function () {
|
|
@@ -2740,6 +3139,7 @@
|
|
|
2740
3139
|
else {
|
|
2741
3140
|
shutdown(true, storedError);
|
|
2742
3141
|
}
|
|
3142
|
+
return null;
|
|
2743
3143
|
});
|
|
2744
3144
|
// Errors must be propagated backward
|
|
2745
3145
|
isOrBecomesErrored(dest, writer._closedPromise, function (storedError) {
|
|
@@ -2749,6 +3149,7 @@
|
|
|
2749
3149
|
else {
|
|
2750
3150
|
shutdown(true, storedError);
|
|
2751
3151
|
}
|
|
3152
|
+
return null;
|
|
2752
3153
|
});
|
|
2753
3154
|
// Closing must be propagated forward
|
|
2754
3155
|
isOrBecomesClosed(source, reader._closedPromise, function () {
|
|
@@ -2758,6 +3159,7 @@
|
|
|
2758
3159
|
else {
|
|
2759
3160
|
shutdown();
|
|
2760
3161
|
}
|
|
3162
|
+
return null;
|
|
2761
3163
|
});
|
|
2762
3164
|
// Closing must be propagated backward
|
|
2763
3165
|
if (WritableStreamCloseQueuedOrInFlight(dest) || dest._state === 'closed') {
|
|
@@ -2805,6 +3207,7 @@
|
|
|
2805
3207
|
}
|
|
2806
3208
|
function doTheRest() {
|
|
2807
3209
|
uponPromise(action(), function () { return finalize(originalIsError, originalError); }, function (newError) { return finalize(true, newError); });
|
|
3210
|
+
return null;
|
|
2808
3211
|
}
|
|
2809
3212
|
}
|
|
2810
3213
|
function shutdown(isError, error) {
|
|
@@ -2831,6 +3234,7 @@
|
|
|
2831
3234
|
else {
|
|
2832
3235
|
resolve(undefined);
|
|
2833
3236
|
}
|
|
3237
|
+
return null;
|
|
2834
3238
|
}
|
|
2835
3239
|
});
|
|
2836
3240
|
}
|
|
@@ -2917,6 +3321,10 @@
|
|
|
2917
3321
|
ReadableStreamDefaultControllerCallPullIfNeeded(this);
|
|
2918
3322
|
}
|
|
2919
3323
|
};
|
|
3324
|
+
/** @internal */
|
|
3325
|
+
ReadableStreamDefaultController.prototype[ReleaseSteps] = function () {
|
|
3326
|
+
// Do nothing.
|
|
3327
|
+
};
|
|
2920
3328
|
return ReadableStreamDefaultController;
|
|
2921
3329
|
}());
|
|
2922
3330
|
Object.defineProperties(ReadableStreamDefaultController.prototype, {
|
|
@@ -2925,6 +3333,9 @@
|
|
|
2925
3333
|
error: { enumerable: true },
|
|
2926
3334
|
desiredSize: { enumerable: true }
|
|
2927
3335
|
});
|
|
3336
|
+
setFunctionName(ReadableStreamDefaultController.prototype.close, 'close');
|
|
3337
|
+
setFunctionName(ReadableStreamDefaultController.prototype.enqueue, 'enqueue');
|
|
3338
|
+
setFunctionName(ReadableStreamDefaultController.prototype.error, 'error');
|
|
2928
3339
|
if (typeof SymbolPolyfill.toStringTag === 'symbol') {
|
|
2929
3340
|
Object.defineProperty(ReadableStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
|
|
2930
3341
|
value: 'ReadableStreamDefaultController',
|
|
@@ -2958,8 +3369,10 @@
|
|
|
2958
3369
|
controller._pullAgain = false;
|
|
2959
3370
|
ReadableStreamDefaultControllerCallPullIfNeeded(controller);
|
|
2960
3371
|
}
|
|
3372
|
+
return null;
|
|
2961
3373
|
}, function (e) {
|
|
2962
3374
|
ReadableStreamDefaultControllerError(controller, e);
|
|
3375
|
+
return null;
|
|
2963
3376
|
});
|
|
2964
3377
|
}
|
|
2965
3378
|
function ReadableStreamDefaultControllerShouldCallPull(controller) {
|
|
@@ -3074,29 +3487,40 @@
|
|
|
3074
3487
|
uponPromise(promiseResolvedWith(startResult), function () {
|
|
3075
3488
|
controller._started = true;
|
|
3076
3489
|
ReadableStreamDefaultControllerCallPullIfNeeded(controller);
|
|
3490
|
+
return null;
|
|
3077
3491
|
}, function (r) {
|
|
3078
3492
|
ReadableStreamDefaultControllerError(controller, r);
|
|
3493
|
+
return null;
|
|
3079
3494
|
});
|
|
3080
3495
|
}
|
|
3081
3496
|
function SetUpReadableStreamDefaultControllerFromUnderlyingSource(stream, underlyingSource, highWaterMark, sizeAlgorithm) {
|
|
3082
3497
|
var controller = Object.create(ReadableStreamDefaultController.prototype);
|
|
3083
|
-
var startAlgorithm
|
|
3084
|
-
var pullAlgorithm
|
|
3085
|
-
var cancelAlgorithm
|
|
3498
|
+
var startAlgorithm;
|
|
3499
|
+
var pullAlgorithm;
|
|
3500
|
+
var cancelAlgorithm;
|
|
3086
3501
|
if (underlyingSource.start !== undefined) {
|
|
3087
3502
|
startAlgorithm = function () { return underlyingSource.start(controller); };
|
|
3088
3503
|
}
|
|
3504
|
+
else {
|
|
3505
|
+
startAlgorithm = function () { return undefined; };
|
|
3506
|
+
}
|
|
3089
3507
|
if (underlyingSource.pull !== undefined) {
|
|
3090
3508
|
pullAlgorithm = function () { return underlyingSource.pull(controller); };
|
|
3091
3509
|
}
|
|
3510
|
+
else {
|
|
3511
|
+
pullAlgorithm = function () { return promiseResolvedWith(undefined); };
|
|
3512
|
+
}
|
|
3092
3513
|
if (underlyingSource.cancel !== undefined) {
|
|
3093
3514
|
cancelAlgorithm = function (reason) { return underlyingSource.cancel(reason); };
|
|
3094
3515
|
}
|
|
3516
|
+
else {
|
|
3517
|
+
cancelAlgorithm = function () { return promiseResolvedWith(undefined); };
|
|
3518
|
+
}
|
|
3095
3519
|
SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
|
|
3096
3520
|
}
|
|
3097
3521
|
// Helper functions for the ReadableStreamDefaultController.
|
|
3098
3522
|
function defaultControllerBrandCheckException$1(name) {
|
|
3099
|
-
return new TypeError("ReadableStreamDefaultController.prototype."
|
|
3523
|
+
return new TypeError("ReadableStreamDefaultController.prototype.".concat(name, " can only be used on a ReadableStreamDefaultController"));
|
|
3100
3524
|
}
|
|
3101
3525
|
|
|
3102
3526
|
function ReadableStreamTee(stream, cloneForBranch2) {
|
|
@@ -3130,7 +3554,7 @@
|
|
|
3130
3554
|
// This needs to be delayed a microtask because it takes at least a microtask to detect errors (using
|
|
3131
3555
|
// reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
|
|
3132
3556
|
// successful synchronously-available reads get ahead of asynchronously-available errors.
|
|
3133
|
-
|
|
3557
|
+
_queueMicrotask(function () {
|
|
3134
3558
|
readAgain = false;
|
|
3135
3559
|
var chunk1 = chunk;
|
|
3136
3560
|
var chunk2 = chunk;
|
|
@@ -3201,6 +3625,7 @@
|
|
|
3201
3625
|
if (!canceled1 || !canceled2) {
|
|
3202
3626
|
resolveCancelPromise(undefined);
|
|
3203
3627
|
}
|
|
3628
|
+
return null;
|
|
3204
3629
|
});
|
|
3205
3630
|
return [branch1, branch2];
|
|
3206
3631
|
}
|
|
@@ -3222,13 +3647,14 @@
|
|
|
3222
3647
|
function forwardReaderError(thisReader) {
|
|
3223
3648
|
uponRejection(thisReader._closedPromise, function (r) {
|
|
3224
3649
|
if (thisReader !== reader) {
|
|
3225
|
-
return;
|
|
3650
|
+
return null;
|
|
3226
3651
|
}
|
|
3227
3652
|
ReadableByteStreamControllerError(branch1._readableStreamController, r);
|
|
3228
3653
|
ReadableByteStreamControllerError(branch2._readableStreamController, r);
|
|
3229
3654
|
if (!canceled1 || !canceled2) {
|
|
3230
3655
|
resolveCancelPromise(undefined);
|
|
3231
3656
|
}
|
|
3657
|
+
return null;
|
|
3232
3658
|
});
|
|
3233
3659
|
}
|
|
3234
3660
|
function pullWithDefaultReader() {
|
|
@@ -3242,7 +3668,7 @@
|
|
|
3242
3668
|
// This needs to be delayed a microtask because it takes at least a microtask to detect errors (using
|
|
3243
3669
|
// reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
|
|
3244
3670
|
// successful synchronously-available reads get ahead of asynchronously-available errors.
|
|
3245
|
-
|
|
3671
|
+
_queueMicrotask(function () {
|
|
3246
3672
|
readAgainForBranch1 = false;
|
|
3247
3673
|
readAgainForBranch2 = false;
|
|
3248
3674
|
var chunk1 = chunk;
|
|
@@ -3310,7 +3736,7 @@
|
|
|
3310
3736
|
// This needs to be delayed a microtask because it takes at least a microtask to detect errors (using
|
|
3311
3737
|
// reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
|
|
3312
3738
|
// successful synchronously-available reads get ahead of asynchronously-available errors.
|
|
3313
|
-
|
|
3739
|
+
_queueMicrotask(function () {
|
|
3314
3740
|
readAgainForBranch1 = false;
|
|
3315
3741
|
readAgainForBranch2 = false;
|
|
3316
3742
|
var byobCanceled = forBranch2 ? canceled2 : canceled1;
|
|
@@ -3369,7 +3795,7 @@
|
|
|
3369
3795
|
reading = false;
|
|
3370
3796
|
}
|
|
3371
3797
|
};
|
|
3372
|
-
ReadableStreamBYOBReaderRead(reader, view, readIntoRequest);
|
|
3798
|
+
ReadableStreamBYOBReaderRead(reader, view, 1, readIntoRequest);
|
|
3373
3799
|
}
|
|
3374
3800
|
function pull1Algorithm() {
|
|
3375
3801
|
if (reading) {
|
|
@@ -3430,6 +3856,109 @@
|
|
|
3430
3856
|
return [branch1, branch2];
|
|
3431
3857
|
}
|
|
3432
3858
|
|
|
3859
|
+
function isReadableStreamLike(stream) {
|
|
3860
|
+
return typeIsObject(stream) && typeof stream.getReader !== 'undefined';
|
|
3861
|
+
}
|
|
3862
|
+
|
|
3863
|
+
function ReadableStreamFrom(source) {
|
|
3864
|
+
if (isReadableStreamLike(source)) {
|
|
3865
|
+
return ReadableStreamFromDefaultReader(source.getReader());
|
|
3866
|
+
}
|
|
3867
|
+
return ReadableStreamFromIterable(source);
|
|
3868
|
+
}
|
|
3869
|
+
function ReadableStreamFromIterable(asyncIterable) {
|
|
3870
|
+
var stream;
|
|
3871
|
+
var iteratorRecord = GetIterator(asyncIterable, 'async');
|
|
3872
|
+
var startAlgorithm = noop;
|
|
3873
|
+
function pullAlgorithm() {
|
|
3874
|
+
var nextResult;
|
|
3875
|
+
try {
|
|
3876
|
+
nextResult = IteratorNext(iteratorRecord);
|
|
3877
|
+
}
|
|
3878
|
+
catch (e) {
|
|
3879
|
+
return promiseRejectedWith(e);
|
|
3880
|
+
}
|
|
3881
|
+
var nextPromise = promiseResolvedWith(nextResult);
|
|
3882
|
+
return transformPromiseWith(nextPromise, function (iterResult) {
|
|
3883
|
+
if (!typeIsObject(iterResult)) {
|
|
3884
|
+
throw new TypeError('The promise returned by the iterator.next() method must fulfill with an object');
|
|
3885
|
+
}
|
|
3886
|
+
var done = IteratorComplete(iterResult);
|
|
3887
|
+
if (done) {
|
|
3888
|
+
ReadableStreamDefaultControllerClose(stream._readableStreamController);
|
|
3889
|
+
}
|
|
3890
|
+
else {
|
|
3891
|
+
var value = IteratorValue(iterResult);
|
|
3892
|
+
ReadableStreamDefaultControllerEnqueue(stream._readableStreamController, value);
|
|
3893
|
+
}
|
|
3894
|
+
});
|
|
3895
|
+
}
|
|
3896
|
+
function cancelAlgorithm(reason) {
|
|
3897
|
+
var iterator = iteratorRecord.iterator;
|
|
3898
|
+
var returnMethod;
|
|
3899
|
+
try {
|
|
3900
|
+
returnMethod = GetMethod(iterator, 'return');
|
|
3901
|
+
}
|
|
3902
|
+
catch (e) {
|
|
3903
|
+
return promiseRejectedWith(e);
|
|
3904
|
+
}
|
|
3905
|
+
if (returnMethod === undefined) {
|
|
3906
|
+
return promiseResolvedWith(undefined);
|
|
3907
|
+
}
|
|
3908
|
+
var returnResult;
|
|
3909
|
+
try {
|
|
3910
|
+
returnResult = reflectCall(returnMethod, iterator, [reason]);
|
|
3911
|
+
}
|
|
3912
|
+
catch (e) {
|
|
3913
|
+
return promiseRejectedWith(e);
|
|
3914
|
+
}
|
|
3915
|
+
var returnPromise = promiseResolvedWith(returnResult);
|
|
3916
|
+
return transformPromiseWith(returnPromise, function (iterResult) {
|
|
3917
|
+
if (!typeIsObject(iterResult)) {
|
|
3918
|
+
throw new TypeError('The promise returned by the iterator.return() method must fulfill with an object');
|
|
3919
|
+
}
|
|
3920
|
+
return undefined;
|
|
3921
|
+
});
|
|
3922
|
+
}
|
|
3923
|
+
stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, 0);
|
|
3924
|
+
return stream;
|
|
3925
|
+
}
|
|
3926
|
+
function ReadableStreamFromDefaultReader(reader) {
|
|
3927
|
+
var stream;
|
|
3928
|
+
var startAlgorithm = noop;
|
|
3929
|
+
function pullAlgorithm() {
|
|
3930
|
+
var readPromise;
|
|
3931
|
+
try {
|
|
3932
|
+
readPromise = reader.read();
|
|
3933
|
+
}
|
|
3934
|
+
catch (e) {
|
|
3935
|
+
return promiseRejectedWith(e);
|
|
3936
|
+
}
|
|
3937
|
+
return transformPromiseWith(readPromise, function (readResult) {
|
|
3938
|
+
if (!typeIsObject(readResult)) {
|
|
3939
|
+
throw new TypeError('The promise returned by the reader.read() method must fulfill with an object');
|
|
3940
|
+
}
|
|
3941
|
+
if (readResult.done) {
|
|
3942
|
+
ReadableStreamDefaultControllerClose(stream._readableStreamController);
|
|
3943
|
+
}
|
|
3944
|
+
else {
|
|
3945
|
+
var value = readResult.value;
|
|
3946
|
+
ReadableStreamDefaultControllerEnqueue(stream._readableStreamController, value);
|
|
3947
|
+
}
|
|
3948
|
+
});
|
|
3949
|
+
}
|
|
3950
|
+
function cancelAlgorithm(reason) {
|
|
3951
|
+
try {
|
|
3952
|
+
return promiseResolvedWith(reader.cancel(reason));
|
|
3953
|
+
}
|
|
3954
|
+
catch (e) {
|
|
3955
|
+
return promiseRejectedWith(e);
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, 0);
|
|
3959
|
+
return stream;
|
|
3960
|
+
}
|
|
3961
|
+
|
|
3433
3962
|
function convertUnderlyingDefaultOrByteSource(source, context) {
|
|
3434
3963
|
assertDictionary(source, context);
|
|
3435
3964
|
var original = source;
|
|
@@ -3441,17 +3970,17 @@
|
|
|
3441
3970
|
return {
|
|
3442
3971
|
autoAllocateChunkSize: autoAllocateChunkSize === undefined ?
|
|
3443
3972
|
undefined :
|
|
3444
|
-
convertUnsignedLongLongWithEnforceRange(autoAllocateChunkSize, context
|
|
3973
|
+
convertUnsignedLongLongWithEnforceRange(autoAllocateChunkSize, "".concat(context, " has member 'autoAllocateChunkSize' that")),
|
|
3445
3974
|
cancel: cancel === undefined ?
|
|
3446
3975
|
undefined :
|
|
3447
|
-
convertUnderlyingSourceCancelCallback(cancel, original, context
|
|
3976
|
+
convertUnderlyingSourceCancelCallback(cancel, original, "".concat(context, " has member 'cancel' that")),
|
|
3448
3977
|
pull: pull === undefined ?
|
|
3449
3978
|
undefined :
|
|
3450
|
-
convertUnderlyingSourcePullCallback(pull, original, context
|
|
3979
|
+
convertUnderlyingSourcePullCallback(pull, original, "".concat(context, " has member 'pull' that")),
|
|
3451
3980
|
start: start === undefined ?
|
|
3452
3981
|
undefined :
|
|
3453
|
-
convertUnderlyingSourceStartCallback(start, original, context
|
|
3454
|
-
type: type === undefined ? undefined : convertReadableStreamType(type, context
|
|
3982
|
+
convertUnderlyingSourceStartCallback(start, original, "".concat(context, " has member 'start' that")),
|
|
3983
|
+
type: type === undefined ? undefined : convertReadableStreamType(type, "".concat(context, " has member 'type' that"))
|
|
3455
3984
|
};
|
|
3456
3985
|
}
|
|
3457
3986
|
function convertUnderlyingSourceCancelCallback(fn, original, context) {
|
|
@@ -3467,28 +3996,13 @@
|
|
|
3467
3996
|
return function (controller) { return reflectCall(fn, original, [controller]); };
|
|
3468
3997
|
}
|
|
3469
3998
|
function convertReadableStreamType(type, context) {
|
|
3470
|
-
type = ""
|
|
3999
|
+
type = "".concat(type);
|
|
3471
4000
|
if (type !== 'bytes') {
|
|
3472
|
-
throw new TypeError(context
|
|
4001
|
+
throw new TypeError("".concat(context, " '").concat(type, "' is not a valid enumeration value for ReadableStreamType"));
|
|
3473
4002
|
}
|
|
3474
4003
|
return type;
|
|
3475
4004
|
}
|
|
3476
4005
|
|
|
3477
|
-
function convertReaderOptions(options, context) {
|
|
3478
|
-
assertDictionary(options, context);
|
|
3479
|
-
var mode = options === null || options === void 0 ? void 0 : options.mode;
|
|
3480
|
-
return {
|
|
3481
|
-
mode: mode === undefined ? undefined : convertReadableStreamReaderMode(mode, context + " has member 'mode' that")
|
|
3482
|
-
};
|
|
3483
|
-
}
|
|
3484
|
-
function convertReadableStreamReaderMode(mode, context) {
|
|
3485
|
-
mode = "" + mode;
|
|
3486
|
-
if (mode !== 'byob') {
|
|
3487
|
-
throw new TypeError(context + " '" + mode + "' is not a valid enumeration value for ReadableStreamReaderMode");
|
|
3488
|
-
}
|
|
3489
|
-
return mode;
|
|
3490
|
-
}
|
|
3491
|
-
|
|
3492
4006
|
function convertIteratorOptions(options, context) {
|
|
3493
4007
|
assertDictionary(options, context);
|
|
3494
4008
|
var preventCancel = options === null || options === void 0 ? void 0 : options.preventCancel;
|
|
@@ -3502,7 +4016,7 @@
|
|
|
3502
4016
|
var preventClose = options === null || options === void 0 ? void 0 : options.preventClose;
|
|
3503
4017
|
var signal = options === null || options === void 0 ? void 0 : options.signal;
|
|
3504
4018
|
if (signal !== undefined) {
|
|
3505
|
-
assertAbortSignal(signal, context
|
|
4019
|
+
assertAbortSignal(signal, "".concat(context, " has member 'signal' that"));
|
|
3506
4020
|
}
|
|
3507
4021
|
return {
|
|
3508
4022
|
preventAbort: Boolean(preventAbort),
|
|
@@ -3513,7 +4027,7 @@
|
|
|
3513
4027
|
}
|
|
3514
4028
|
function assertAbortSignal(signal, context) {
|
|
3515
4029
|
if (!isAbortSignal(signal)) {
|
|
3516
|
-
throw new TypeError(context
|
|
4030
|
+
throw new TypeError("".concat(context, " is not an AbortSignal."));
|
|
3517
4031
|
}
|
|
3518
4032
|
}
|
|
3519
4033
|
|
|
@@ -3521,10 +4035,10 @@
|
|
|
3521
4035
|
assertDictionary(pair, context);
|
|
3522
4036
|
var readable = pair === null || pair === void 0 ? void 0 : pair.readable;
|
|
3523
4037
|
assertRequiredField(readable, 'readable', 'ReadableWritablePair');
|
|
3524
|
-
assertReadableStream(readable, context
|
|
4038
|
+
assertReadableStream(readable, "".concat(context, " has member 'readable' that"));
|
|
3525
4039
|
var writable = pair === null || pair === void 0 ? void 0 : pair.writable;
|
|
3526
4040
|
assertRequiredField(writable, 'writable', 'ReadableWritablePair');
|
|
3527
|
-
assertWritableStream(writable, context
|
|
4041
|
+
assertWritableStream(writable, "".concat(context, " has member 'writable' that"));
|
|
3528
4042
|
return { readable: readable, writable: writable };
|
|
3529
4043
|
}
|
|
3530
4044
|
|
|
@@ -3669,8 +4183,20 @@
|
|
|
3669
4183
|
var options = convertIteratorOptions(rawOptions, 'First parameter');
|
|
3670
4184
|
return AcquireReadableStreamAsyncIterator(this, options.preventCancel);
|
|
3671
4185
|
};
|
|
4186
|
+
/**
|
|
4187
|
+
* Creates a new ReadableStream wrapping the provided iterable or async iterable.
|
|
4188
|
+
*
|
|
4189
|
+
* This can be used to adapt various kinds of objects into a readable stream,
|
|
4190
|
+
* such as an array, an async generator, or a Node.js readable stream.
|
|
4191
|
+
*/
|
|
4192
|
+
ReadableStream.from = function (asyncIterable) {
|
|
4193
|
+
return ReadableStreamFrom(asyncIterable);
|
|
4194
|
+
};
|
|
3672
4195
|
return ReadableStream;
|
|
3673
4196
|
}());
|
|
4197
|
+
Object.defineProperties(ReadableStream, {
|
|
4198
|
+
from: { enumerable: true }
|
|
4199
|
+
});
|
|
3674
4200
|
Object.defineProperties(ReadableStream.prototype, {
|
|
3675
4201
|
cancel: { enumerable: true },
|
|
3676
4202
|
getReader: { enumerable: true },
|
|
@@ -3680,6 +4206,13 @@
|
|
|
3680
4206
|
values: { enumerable: true },
|
|
3681
4207
|
locked: { enumerable: true }
|
|
3682
4208
|
});
|
|
4209
|
+
setFunctionName(ReadableStream.from, 'from');
|
|
4210
|
+
setFunctionName(ReadableStream.prototype.cancel, 'cancel');
|
|
4211
|
+
setFunctionName(ReadableStream.prototype.getReader, 'getReader');
|
|
4212
|
+
setFunctionName(ReadableStream.prototype.pipeThrough, 'pipeThrough');
|
|
4213
|
+
setFunctionName(ReadableStream.prototype.pipeTo, 'pipeTo');
|
|
4214
|
+
setFunctionName(ReadableStream.prototype.tee, 'tee');
|
|
4215
|
+
setFunctionName(ReadableStream.prototype.values, 'values');
|
|
3683
4216
|
if (typeof SymbolPolyfill.toStringTag === 'symbol') {
|
|
3684
4217
|
Object.defineProperty(ReadableStream.prototype, SymbolPolyfill.toStringTag, {
|
|
3685
4218
|
value: 'ReadableStream',
|
|
@@ -3745,10 +4278,11 @@
|
|
|
3745
4278
|
ReadableStreamClose(stream);
|
|
3746
4279
|
var reader = stream._reader;
|
|
3747
4280
|
if (reader !== undefined && IsReadableStreamBYOBReader(reader)) {
|
|
3748
|
-
reader._readIntoRequests
|
|
4281
|
+
var readIntoRequests = reader._readIntoRequests;
|
|
4282
|
+
reader._readIntoRequests = new SimpleQueue();
|
|
4283
|
+
readIntoRequests.forEach(function (readIntoRequest) {
|
|
3749
4284
|
readIntoRequest._closeSteps(undefined);
|
|
3750
4285
|
});
|
|
3751
|
-
reader._readIntoRequests = new SimpleQueue();
|
|
3752
4286
|
}
|
|
3753
4287
|
var sourceCancelPromise = stream._readableStreamController[CancelSteps](reason);
|
|
3754
4288
|
return transformPromiseWith(sourceCancelPromise, noop);
|
|
@@ -3761,10 +4295,11 @@
|
|
|
3761
4295
|
}
|
|
3762
4296
|
defaultReaderClosedPromiseResolve(reader);
|
|
3763
4297
|
if (IsReadableStreamDefaultReader(reader)) {
|
|
3764
|
-
reader._readRequests
|
|
4298
|
+
var readRequests = reader._readRequests;
|
|
4299
|
+
reader._readRequests = new SimpleQueue();
|
|
4300
|
+
readRequests.forEach(function (readRequest) {
|
|
3765
4301
|
readRequest._closeSteps();
|
|
3766
4302
|
});
|
|
3767
|
-
reader._readRequests = new SimpleQueue();
|
|
3768
4303
|
}
|
|
3769
4304
|
}
|
|
3770
4305
|
function ReadableStreamError(stream, e) {
|
|
@@ -3776,21 +4311,15 @@
|
|
|
3776
4311
|
}
|
|
3777
4312
|
defaultReaderClosedPromiseReject(reader, e);
|
|
3778
4313
|
if (IsReadableStreamDefaultReader(reader)) {
|
|
3779
|
-
reader
|
|
3780
|
-
readRequest._errorSteps(e);
|
|
3781
|
-
});
|
|
3782
|
-
reader._readRequests = new SimpleQueue();
|
|
4314
|
+
ReadableStreamDefaultReaderErrorReadRequests(reader, e);
|
|
3783
4315
|
}
|
|
3784
4316
|
else {
|
|
3785
|
-
reader
|
|
3786
|
-
readIntoRequest._errorSteps(e);
|
|
3787
|
-
});
|
|
3788
|
-
reader._readIntoRequests = new SimpleQueue();
|
|
4317
|
+
ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e);
|
|
3789
4318
|
}
|
|
3790
4319
|
}
|
|
3791
4320
|
// Helper functions for the ReadableStream.
|
|
3792
4321
|
function streamBrandCheckException$1(name) {
|
|
3793
|
-
return new TypeError("ReadableStream.prototype."
|
|
4322
|
+
return new TypeError("ReadableStream.prototype.".concat(name, " can only be used on a ReadableStream"));
|
|
3794
4323
|
}
|
|
3795
4324
|
|
|
3796
4325
|
function convertQueuingStrategyInit(init, context) {
|
|
@@ -3806,16 +4335,7 @@
|
|
|
3806
4335
|
var byteLengthSizeFunction = function (chunk) {
|
|
3807
4336
|
return chunk.byteLength;
|
|
3808
4337
|
};
|
|
3809
|
-
|
|
3810
|
-
Object.defineProperty(byteLengthSizeFunction, 'name', {
|
|
3811
|
-
value: 'size',
|
|
3812
|
-
configurable: true
|
|
3813
|
-
});
|
|
3814
|
-
}
|
|
3815
|
-
catch (_a) {
|
|
3816
|
-
// This property is non-configurable in older browsers, so ignore if this throws.
|
|
3817
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#browser_compatibility
|
|
3818
|
-
}
|
|
4338
|
+
setFunctionName(byteLengthSizeFunction, 'size');
|
|
3819
4339
|
/**
|
|
3820
4340
|
* A queuing strategy that counts the number of bytes in each chunk.
|
|
3821
4341
|
*
|
|
@@ -3867,7 +4387,7 @@
|
|
|
3867
4387
|
}
|
|
3868
4388
|
// Helper functions for the ByteLengthQueuingStrategy.
|
|
3869
4389
|
function byteLengthBrandCheckException(name) {
|
|
3870
|
-
return new TypeError("ByteLengthQueuingStrategy.prototype."
|
|
4390
|
+
return new TypeError("ByteLengthQueuingStrategy.prototype.".concat(name, " can only be used on a ByteLengthQueuingStrategy"));
|
|
3871
4391
|
}
|
|
3872
4392
|
function IsByteLengthQueuingStrategy(x) {
|
|
3873
4393
|
if (!typeIsObject(x)) {
|
|
@@ -3883,16 +4403,7 @@
|
|
|
3883
4403
|
var countSizeFunction = function () {
|
|
3884
4404
|
return 1;
|
|
3885
4405
|
};
|
|
3886
|
-
|
|
3887
|
-
Object.defineProperty(countSizeFunction, 'name', {
|
|
3888
|
-
value: 'size',
|
|
3889
|
-
configurable: true
|
|
3890
|
-
});
|
|
3891
|
-
}
|
|
3892
|
-
catch (_a) {
|
|
3893
|
-
// This property is non-configurable in older browsers, so ignore if this throws.
|
|
3894
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#browser_compatibility
|
|
3895
|
-
}
|
|
4406
|
+
setFunctionName(countSizeFunction, 'size');
|
|
3896
4407
|
/**
|
|
3897
4408
|
* A queuing strategy that counts the number of chunks.
|
|
3898
4409
|
*
|
|
@@ -3945,7 +4456,7 @@
|
|
|
3945
4456
|
}
|
|
3946
4457
|
// Helper functions for the CountQueuingStrategy.
|
|
3947
4458
|
function countBrandCheckException(name) {
|
|
3948
|
-
return new TypeError("CountQueuingStrategy.prototype."
|
|
4459
|
+
return new TypeError("CountQueuingStrategy.prototype.".concat(name, " can only be used on a CountQueuingStrategy"));
|
|
3949
4460
|
}
|
|
3950
4461
|
function IsCountQueuingStrategy(x) {
|
|
3951
4462
|
if (!typeIsObject(x)) {
|
|
@@ -3959,22 +4470,26 @@
|
|
|
3959
4470
|
|
|
3960
4471
|
function convertTransformer(original, context) {
|
|
3961
4472
|
assertDictionary(original, context);
|
|
4473
|
+
var cancel = original === null || original === void 0 ? void 0 : original.cancel;
|
|
3962
4474
|
var flush = original === null || original === void 0 ? void 0 : original.flush;
|
|
3963
4475
|
var readableType = original === null || original === void 0 ? void 0 : original.readableType;
|
|
3964
4476
|
var start = original === null || original === void 0 ? void 0 : original.start;
|
|
3965
4477
|
var transform = original === null || original === void 0 ? void 0 : original.transform;
|
|
3966
4478
|
var writableType = original === null || original === void 0 ? void 0 : original.writableType;
|
|
3967
4479
|
return {
|
|
4480
|
+
cancel: cancel === undefined ?
|
|
4481
|
+
undefined :
|
|
4482
|
+
convertTransformerCancelCallback(cancel, original, "".concat(context, " has member 'cancel' that")),
|
|
3968
4483
|
flush: flush === undefined ?
|
|
3969
4484
|
undefined :
|
|
3970
|
-
convertTransformerFlushCallback(flush, original, context
|
|
4485
|
+
convertTransformerFlushCallback(flush, original, "".concat(context, " has member 'flush' that")),
|
|
3971
4486
|
readableType: readableType,
|
|
3972
4487
|
start: start === undefined ?
|
|
3973
4488
|
undefined :
|
|
3974
|
-
convertTransformerStartCallback(start, original, context
|
|
4489
|
+
convertTransformerStartCallback(start, original, "".concat(context, " has member 'start' that")),
|
|
3975
4490
|
transform: transform === undefined ?
|
|
3976
4491
|
undefined :
|
|
3977
|
-
convertTransformerTransformCallback(transform, original, context
|
|
4492
|
+
convertTransformerTransformCallback(transform, original, "".concat(context, " has member 'transform' that")),
|
|
3978
4493
|
writableType: writableType
|
|
3979
4494
|
};
|
|
3980
4495
|
}
|
|
@@ -3990,6 +4505,10 @@
|
|
|
3990
4505
|
assertFunction(fn, context);
|
|
3991
4506
|
return function (chunk, controller) { return promiseCall(fn, original, [chunk, controller]); };
|
|
3992
4507
|
}
|
|
4508
|
+
function convertTransformerCancelCallback(fn, original, context) {
|
|
4509
|
+
assertFunction(fn, context);
|
|
4510
|
+
return function (reason) { return promiseCall(fn, original, [reason]); };
|
|
4511
|
+
}
|
|
3993
4512
|
|
|
3994
4513
|
// Class TransformStream
|
|
3995
4514
|
/**
|
|
@@ -4090,8 +4609,7 @@
|
|
|
4090
4609
|
return TransformStreamDefaultSourcePullAlgorithm(stream);
|
|
4091
4610
|
}
|
|
4092
4611
|
function cancelAlgorithm(reason) {
|
|
4093
|
-
|
|
4094
|
-
return promiseResolvedWith(undefined);
|
|
4612
|
+
return TransformStreamDefaultSourceCancelAlgorithm(stream, reason);
|
|
4095
4613
|
}
|
|
4096
4614
|
stream._readable = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
|
|
4097
4615
|
// The [[backpressure]] slot is set to undefined so that it can be initialised by TransformStreamSetBackpressure.
|
|
@@ -4118,6 +4636,9 @@
|
|
|
4118
4636
|
function TransformStreamErrorWritableAndUnblockWrite(stream, e) {
|
|
4119
4637
|
TransformStreamDefaultControllerClearAlgorithms(stream._transformStreamController);
|
|
4120
4638
|
WritableStreamDefaultControllerErrorIfNeeded(stream._writable._writableStreamController, e);
|
|
4639
|
+
TransformStreamUnblockWrite(stream);
|
|
4640
|
+
}
|
|
4641
|
+
function TransformStreamUnblockWrite(stream) {
|
|
4121
4642
|
if (stream._backpressure) {
|
|
4122
4643
|
// Pretend that pull() was called to permit any pending write() calls to complete. TransformStreamSetBackpressure()
|
|
4123
4644
|
// cannot be called from enqueue() or pull() once the ReadableStream is errored, so this will will be the final time
|
|
@@ -4195,6 +4716,9 @@
|
|
|
4195
4716
|
terminate: { enumerable: true },
|
|
4196
4717
|
desiredSize: { enumerable: true }
|
|
4197
4718
|
});
|
|
4719
|
+
setFunctionName(TransformStreamDefaultController.prototype.enqueue, 'enqueue');
|
|
4720
|
+
setFunctionName(TransformStreamDefaultController.prototype.error, 'error');
|
|
4721
|
+
setFunctionName(TransformStreamDefaultController.prototype.terminate, 'terminate');
|
|
4198
4722
|
if (typeof SymbolPolyfill.toStringTag === 'symbol') {
|
|
4199
4723
|
Object.defineProperty(TransformStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
|
|
4200
4724
|
value: 'TransformStreamDefaultController',
|
|
@@ -4211,35 +4735,53 @@
|
|
|
4211
4735
|
}
|
|
4212
4736
|
return x instanceof TransformStreamDefaultController;
|
|
4213
4737
|
}
|
|
4214
|
-
function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm) {
|
|
4738
|
+
function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm, cancelAlgorithm) {
|
|
4215
4739
|
controller._controlledTransformStream = stream;
|
|
4216
4740
|
stream._transformStreamController = controller;
|
|
4217
4741
|
controller._transformAlgorithm = transformAlgorithm;
|
|
4218
4742
|
controller._flushAlgorithm = flushAlgorithm;
|
|
4743
|
+
controller._cancelAlgorithm = cancelAlgorithm;
|
|
4744
|
+
controller._finishPromise = undefined;
|
|
4745
|
+
controller._finishPromise_resolve = undefined;
|
|
4746
|
+
controller._finishPromise_reject = undefined;
|
|
4219
4747
|
}
|
|
4220
4748
|
function SetUpTransformStreamDefaultControllerFromTransformer(stream, transformer) {
|
|
4221
4749
|
var controller = Object.create(TransformStreamDefaultController.prototype);
|
|
4222
|
-
var transformAlgorithm
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
return promiseResolvedWith(undefined);
|
|
4226
|
-
}
|
|
4227
|
-
catch (transformResultE) {
|
|
4228
|
-
return promiseRejectedWith(transformResultE);
|
|
4229
|
-
}
|
|
4230
|
-
};
|
|
4231
|
-
var flushAlgorithm = function () { return promiseResolvedWith(undefined); };
|
|
4750
|
+
var transformAlgorithm;
|
|
4751
|
+
var flushAlgorithm;
|
|
4752
|
+
var cancelAlgorithm;
|
|
4232
4753
|
if (transformer.transform !== undefined) {
|
|
4233
4754
|
transformAlgorithm = function (chunk) { return transformer.transform(chunk, controller); };
|
|
4234
4755
|
}
|
|
4756
|
+
else {
|
|
4757
|
+
transformAlgorithm = function (chunk) {
|
|
4758
|
+
try {
|
|
4759
|
+
TransformStreamDefaultControllerEnqueue(controller, chunk);
|
|
4760
|
+
return promiseResolvedWith(undefined);
|
|
4761
|
+
}
|
|
4762
|
+
catch (transformResultE) {
|
|
4763
|
+
return promiseRejectedWith(transformResultE);
|
|
4764
|
+
}
|
|
4765
|
+
};
|
|
4766
|
+
}
|
|
4235
4767
|
if (transformer.flush !== undefined) {
|
|
4236
4768
|
flushAlgorithm = function () { return transformer.flush(controller); };
|
|
4237
4769
|
}
|
|
4238
|
-
|
|
4770
|
+
else {
|
|
4771
|
+
flushAlgorithm = function () { return promiseResolvedWith(undefined); };
|
|
4772
|
+
}
|
|
4773
|
+
if (transformer.cancel !== undefined) {
|
|
4774
|
+
cancelAlgorithm = function (reason) { return transformer.cancel(reason); };
|
|
4775
|
+
}
|
|
4776
|
+
else {
|
|
4777
|
+
cancelAlgorithm = function () { return promiseResolvedWith(undefined); };
|
|
4778
|
+
}
|
|
4779
|
+
SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm, cancelAlgorithm);
|
|
4239
4780
|
}
|
|
4240
4781
|
function TransformStreamDefaultControllerClearAlgorithms(controller) {
|
|
4241
4782
|
controller._transformAlgorithm = undefined;
|
|
4242
4783
|
controller._flushAlgorithm = undefined;
|
|
4784
|
+
controller._cancelAlgorithm = undefined;
|
|
4243
4785
|
}
|
|
4244
4786
|
function TransformStreamDefaultControllerEnqueue(controller, chunk) {
|
|
4245
4787
|
var stream = controller._controlledTransformStream;
|
|
@@ -4296,27 +4838,66 @@
|
|
|
4296
4838
|
return TransformStreamDefaultControllerPerformTransform(controller, chunk);
|
|
4297
4839
|
}
|
|
4298
4840
|
function TransformStreamDefaultSinkAbortAlgorithm(stream, reason) {
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4841
|
+
var controller = stream._transformStreamController;
|
|
4842
|
+
if (controller._finishPromise !== undefined) {
|
|
4843
|
+
return controller._finishPromise;
|
|
4844
|
+
}
|
|
4845
|
+
// stream._readable cannot change after construction, so caching it across a call to user code is safe.
|
|
4846
|
+
var readable = stream._readable;
|
|
4847
|
+
// Assign the _finishPromise now so that if _cancelAlgorithm calls readable.cancel() internally,
|
|
4848
|
+
// we don't run the _cancelAlgorithm again.
|
|
4849
|
+
controller._finishPromise = newPromise(function (resolve, reject) {
|
|
4850
|
+
controller._finishPromise_resolve = resolve;
|
|
4851
|
+
controller._finishPromise_reject = reject;
|
|
4852
|
+
});
|
|
4853
|
+
var cancelPromise = controller._cancelAlgorithm(reason);
|
|
4854
|
+
TransformStreamDefaultControllerClearAlgorithms(controller);
|
|
4855
|
+
uponPromise(cancelPromise, function () {
|
|
4856
|
+
if (readable._state === 'errored') {
|
|
4857
|
+
defaultControllerFinishPromiseReject(controller, readable._storedError);
|
|
4858
|
+
}
|
|
4859
|
+
else {
|
|
4860
|
+
ReadableStreamDefaultControllerError(readable._readableStreamController, reason);
|
|
4861
|
+
defaultControllerFinishPromiseResolve(controller);
|
|
4862
|
+
}
|
|
4863
|
+
return null;
|
|
4864
|
+
}, function (r) {
|
|
4865
|
+
ReadableStreamDefaultControllerError(readable._readableStreamController, r);
|
|
4866
|
+
defaultControllerFinishPromiseReject(controller, r);
|
|
4867
|
+
return null;
|
|
4868
|
+
});
|
|
4869
|
+
return controller._finishPromise;
|
|
4303
4870
|
}
|
|
4304
4871
|
function TransformStreamDefaultSinkCloseAlgorithm(stream) {
|
|
4872
|
+
var controller = stream._transformStreamController;
|
|
4873
|
+
if (controller._finishPromise !== undefined) {
|
|
4874
|
+
return controller._finishPromise;
|
|
4875
|
+
}
|
|
4305
4876
|
// stream._readable cannot change after construction, so caching it across a call to user code is safe.
|
|
4306
4877
|
var readable = stream._readable;
|
|
4307
|
-
|
|
4878
|
+
// Assign the _finishPromise now so that if _flushAlgorithm calls readable.cancel() internally,
|
|
4879
|
+
// we don't also run the _cancelAlgorithm.
|
|
4880
|
+
controller._finishPromise = newPromise(function (resolve, reject) {
|
|
4881
|
+
controller._finishPromise_resolve = resolve;
|
|
4882
|
+
controller._finishPromise_reject = reject;
|
|
4883
|
+
});
|
|
4308
4884
|
var flushPromise = controller._flushAlgorithm();
|
|
4309
4885
|
TransformStreamDefaultControllerClearAlgorithms(controller);
|
|
4310
|
-
|
|
4311
|
-
return transformPromiseWith(flushPromise, function () {
|
|
4886
|
+
uponPromise(flushPromise, function () {
|
|
4312
4887
|
if (readable._state === 'errored') {
|
|
4313
|
-
|
|
4888
|
+
defaultControllerFinishPromiseReject(controller, readable._storedError);
|
|
4314
4889
|
}
|
|
4315
|
-
|
|
4890
|
+
else {
|
|
4891
|
+
ReadableStreamDefaultControllerClose(readable._readableStreamController);
|
|
4892
|
+
defaultControllerFinishPromiseResolve(controller);
|
|
4893
|
+
}
|
|
4894
|
+
return null;
|
|
4316
4895
|
}, function (r) {
|
|
4317
|
-
|
|
4318
|
-
|
|
4896
|
+
ReadableStreamDefaultControllerError(readable._readableStreamController, r);
|
|
4897
|
+
defaultControllerFinishPromiseReject(controller, r);
|
|
4898
|
+
return null;
|
|
4319
4899
|
});
|
|
4900
|
+
return controller._finishPromise;
|
|
4320
4901
|
}
|
|
4321
4902
|
// TransformStreamDefaultSource Algorithms
|
|
4322
4903
|
function TransformStreamDefaultSourcePullAlgorithm(stream) {
|
|
@@ -4325,13 +4906,64 @@
|
|
|
4325
4906
|
// Prevent the next pull() call until there is backpressure.
|
|
4326
4907
|
return stream._backpressureChangePromise;
|
|
4327
4908
|
}
|
|
4909
|
+
function TransformStreamDefaultSourceCancelAlgorithm(stream, reason) {
|
|
4910
|
+
var controller = stream._transformStreamController;
|
|
4911
|
+
if (controller._finishPromise !== undefined) {
|
|
4912
|
+
return controller._finishPromise;
|
|
4913
|
+
}
|
|
4914
|
+
// stream._writable cannot change after construction, so caching it across a call to user code is safe.
|
|
4915
|
+
var writable = stream._writable;
|
|
4916
|
+
// Assign the _finishPromise now so that if _flushAlgorithm calls writable.abort() or
|
|
4917
|
+
// writable.cancel() internally, we don't run the _cancelAlgorithm again, or also run the
|
|
4918
|
+
// _flushAlgorithm.
|
|
4919
|
+
controller._finishPromise = newPromise(function (resolve, reject) {
|
|
4920
|
+
controller._finishPromise_resolve = resolve;
|
|
4921
|
+
controller._finishPromise_reject = reject;
|
|
4922
|
+
});
|
|
4923
|
+
var cancelPromise = controller._cancelAlgorithm(reason);
|
|
4924
|
+
TransformStreamDefaultControllerClearAlgorithms(controller);
|
|
4925
|
+
uponPromise(cancelPromise, function () {
|
|
4926
|
+
if (writable._state === 'errored') {
|
|
4927
|
+
defaultControllerFinishPromiseReject(controller, writable._storedError);
|
|
4928
|
+
}
|
|
4929
|
+
else {
|
|
4930
|
+
WritableStreamDefaultControllerErrorIfNeeded(writable._writableStreamController, reason);
|
|
4931
|
+
TransformStreamUnblockWrite(stream);
|
|
4932
|
+
defaultControllerFinishPromiseResolve(controller);
|
|
4933
|
+
}
|
|
4934
|
+
return null;
|
|
4935
|
+
}, function (r) {
|
|
4936
|
+
WritableStreamDefaultControllerErrorIfNeeded(writable._writableStreamController, r);
|
|
4937
|
+
TransformStreamUnblockWrite(stream);
|
|
4938
|
+
defaultControllerFinishPromiseReject(controller, r);
|
|
4939
|
+
return null;
|
|
4940
|
+
});
|
|
4941
|
+
return controller._finishPromise;
|
|
4942
|
+
}
|
|
4328
4943
|
// Helper functions for the TransformStreamDefaultController.
|
|
4329
4944
|
function defaultControllerBrandCheckException(name) {
|
|
4330
|
-
return new TypeError("TransformStreamDefaultController.prototype."
|
|
4945
|
+
return new TypeError("TransformStreamDefaultController.prototype.".concat(name, " can only be used on a TransformStreamDefaultController"));
|
|
4946
|
+
}
|
|
4947
|
+
function defaultControllerFinishPromiseResolve(controller) {
|
|
4948
|
+
if (controller._finishPromise_resolve === undefined) {
|
|
4949
|
+
return;
|
|
4950
|
+
}
|
|
4951
|
+
controller._finishPromise_resolve();
|
|
4952
|
+
controller._finishPromise_resolve = undefined;
|
|
4953
|
+
controller._finishPromise_reject = undefined;
|
|
4954
|
+
}
|
|
4955
|
+
function defaultControllerFinishPromiseReject(controller, reason) {
|
|
4956
|
+
if (controller._finishPromise_reject === undefined) {
|
|
4957
|
+
return;
|
|
4958
|
+
}
|
|
4959
|
+
setPromiseIsHandledToTrue(controller._finishPromise);
|
|
4960
|
+
controller._finishPromise_reject(reason);
|
|
4961
|
+
controller._finishPromise_resolve = undefined;
|
|
4962
|
+
controller._finishPromise_reject = undefined;
|
|
4331
4963
|
}
|
|
4332
4964
|
// Helper functions for the TransformStream.
|
|
4333
4965
|
function streamBrandCheckException(name) {
|
|
4334
|
-
return new TypeError("TransformStream.prototype."
|
|
4966
|
+
return new TypeError("TransformStream.prototype.".concat(name, " can only be used on a TransformStream"));
|
|
4335
4967
|
}
|
|
4336
4968
|
|
|
4337
4969
|
var exports$1 = {
|
|
@@ -4376,7 +5008,5 @@
|
|
|
4376
5008
|
exports.WritableStreamDefaultController = WritableStreamDefaultController;
|
|
4377
5009
|
exports.WritableStreamDefaultWriter = WritableStreamDefaultWriter;
|
|
4378
5010
|
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
})));
|
|
5011
|
+
}));
|
|
4382
5012
|
//# sourceMappingURL=polyfill.js.map
|