web-streams-polyfill 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/polyfill.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * web-streams-polyfill v3.1.1
2
+ * web-streams-polyfill v3.2.0
3
3
  */
4
4
  (function (global, factory) {
5
5
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -1243,6 +1243,9 @@
1243
1243
  ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
1244
1244
  }
1245
1245
  else {
1246
+ if (controller._pendingPullIntos.length > 0) {
1247
+ ReadableByteStreamControllerShiftPendingPullInto(controller);
1248
+ }
1246
1249
  var transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
1247
1250
  ReadableStreamFulfillReadRequest(stream, transferredView, false);
1248
1251
  }
@@ -1328,8 +1331,9 @@
1328
1331
  if (firstDescriptor.bytesFilled + view.byteLength > firstDescriptor.byteLength) {
1329
1332
  throw new RangeError('The region specified by view is larger than byobRequest');
1330
1333
  }
1334
+ var viewByteLength = view.byteLength;
1331
1335
  firstDescriptor.buffer = TransferArrayBuffer(view.buffer);
1332
- ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
1336
+ ReadableByteStreamControllerRespondInternal(controller, viewByteLength);
1333
1337
  }
1334
1338
  function SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize) {
1335
1339
  controller._controlledReadableByteStream = stream;
@@ -2288,6 +2292,10 @@
2288
2292
  Object.defineProperty(WritableStreamDefaultController.prototype, "abortReason", {
2289
2293
  /**
2290
2294
  * The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted.
2295
+ *
2296
+ * @deprecated
2297
+ * This property has been removed from the specification, see https://github.com/whatwg/streams/pull/1177.
2298
+ * Use {@link WritableStreamDefaultController.signal}'s `reason` instead.
2291
2299
  */
2292
2300
  get: function () {
2293
2301
  if (!IsWritableStreamDefaultController(this)) {
@@ -2350,6 +2358,8 @@
2350
2358
  return WritableStreamDefaultController;
2351
2359
  }());
2352
2360
  Object.defineProperties(WritableStreamDefaultController.prototype, {
2361
+ abortReason: { enumerable: true },
2362
+ signal: { enumerable: true },
2353
2363
  error: { enumerable: true }
2354
2364
  });
2355
2365
  if (typeof SymbolPolyfill.toStringTag === 'symbol') {
@@ -3098,6 +3108,7 @@
3098
3108
  function ReadableStreamDefaultTee(stream, cloneForBranch2) {
3099
3109
  var reader = AcquireReadableStreamDefaultReader(stream);
3100
3110
  var reading = false;
3111
+ var readAgain = false;
3101
3112
  var canceled1 = false;
3102
3113
  var canceled2 = false;
3103
3114
  var reason1;
@@ -3110,6 +3121,7 @@
3110
3121
  });
3111
3122
  function pullAlgorithm() {
3112
3123
  if (reading) {
3124
+ readAgain = true;
3113
3125
  return promiseResolvedWith(undefined);
3114
3126
  }
3115
3127
  reading = true;
@@ -3119,7 +3131,7 @@
3119
3131
  // reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
3120
3132
  // successful synchronously-available reads get ahead of asynchronously-available errors.
3121
3133
  queueMicrotask(function () {
3122
- reading = false;
3134
+ readAgain = false;
3123
3135
  var chunk1 = chunk;
3124
3136
  var chunk2 = chunk;
3125
3137
  // There is no way to access the cloning code right now in the reference implementation.
@@ -3133,6 +3145,10 @@
3133
3145
  if (!canceled2) {
3134
3146
  ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, chunk2);
3135
3147
  }
3148
+ reading = false;
3149
+ if (readAgain) {
3150
+ pullAlgorithm();
3151
+ }
3136
3152
  });
3137
3153
  },
3138
3154
  _closeSteps: function () {
@@ -3191,6 +3207,8 @@
3191
3207
  function ReadableByteStreamTee(stream) {
3192
3208
  var reader = AcquireReadableStreamDefaultReader(stream);
3193
3209
  var reading = false;
3210
+ var readAgainForBranch1 = false;
3211
+ var readAgainForBranch2 = false;
3194
3212
  var canceled1 = false;
3195
3213
  var canceled2 = false;
3196
3214
  var reason1;
@@ -3225,7 +3243,8 @@
3225
3243
  // reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
3226
3244
  // successful synchronously-available reads get ahead of asynchronously-available errors.
3227
3245
  queueMicrotask(function () {
3228
- reading = false;
3246
+ readAgainForBranch1 = false;
3247
+ readAgainForBranch2 = false;
3229
3248
  var chunk1 = chunk;
3230
3249
  var chunk2 = chunk;
3231
3250
  if (!canceled1 && !canceled2) {
@@ -3245,6 +3264,13 @@
3245
3264
  if (!canceled2) {
3246
3265
  ReadableByteStreamControllerEnqueue(branch2._readableStreamController, chunk2);
3247
3266
  }
3267
+ reading = false;
3268
+ if (readAgainForBranch1) {
3269
+ pull1Algorithm();
3270
+ }
3271
+ else if (readAgainForBranch2) {
3272
+ pull2Algorithm();
3273
+ }
3248
3274
  });
3249
3275
  },
3250
3276
  _closeSteps: function () {
@@ -3285,7 +3311,8 @@
3285
3311
  // reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
3286
3312
  // successful synchronously-available reads get ahead of asynchronously-available errors.
3287
3313
  queueMicrotask(function () {
3288
- reading = false;
3314
+ readAgainForBranch1 = false;
3315
+ readAgainForBranch2 = false;
3289
3316
  var byobCanceled = forBranch2 ? canceled2 : canceled1;
3290
3317
  var otherCanceled = forBranch2 ? canceled1 : canceled2;
3291
3318
  if (!otherCanceled) {
@@ -3307,6 +3334,13 @@
3307
3334
  else if (!byobCanceled) {
3308
3335
  ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk);
3309
3336
  }
3337
+ reading = false;
3338
+ if (readAgainForBranch1) {
3339
+ pull1Algorithm();
3340
+ }
3341
+ else if (readAgainForBranch2) {
3342
+ pull2Algorithm();
3343
+ }
3310
3344
  });
3311
3345
  },
3312
3346
  _closeSteps: function (chunk) {
@@ -3339,6 +3373,7 @@
3339
3373
  }
3340
3374
  function pull1Algorithm() {
3341
3375
  if (reading) {
3376
+ readAgainForBranch1 = true;
3342
3377
  return promiseResolvedWith(undefined);
3343
3378
  }
3344
3379
  reading = true;
@@ -3353,6 +3388,7 @@
3353
3388
  }
3354
3389
  function pull2Algorithm() {
3355
3390
  if (reading) {
3391
+ readAgainForBranch2 = true;
3356
3392
  return promiseResolvedWith(undefined);
3357
3393
  }
3358
3394
  reading = true;