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.
@@ -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) :
@@ -1201,6 +1201,9 @@
1201
1201
  ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
1202
1202
  }
1203
1203
  else {
1204
+ if (controller._pendingPullIntos.length > 0) {
1205
+ ReadableByteStreamControllerShiftPendingPullInto(controller);
1206
+ }
1204
1207
  const transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
1205
1208
  ReadableStreamFulfillReadRequest(stream, transferredView, false);
1206
1209
  }
@@ -1286,8 +1289,9 @@
1286
1289
  if (firstDescriptor.bytesFilled + view.byteLength > firstDescriptor.byteLength) {
1287
1290
  throw new RangeError('The region specified by view is larger than byobRequest');
1288
1291
  }
1292
+ const viewByteLength = view.byteLength;
1289
1293
  firstDescriptor.buffer = TransferArrayBuffer(view.buffer);
1290
- ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
1294
+ ReadableByteStreamControllerRespondInternal(controller, viewByteLength);
1291
1295
  }
1292
1296
  function SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize) {
1293
1297
  controller._controlledReadableByteStream = stream;
@@ -2214,6 +2218,10 @@
2214
2218
  }
2215
2219
  /**
2216
2220
  * The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted.
2221
+ *
2222
+ * @deprecated
2223
+ * This property has been removed from the specification, see https://github.com/whatwg/streams/pull/1177.
2224
+ * Use {@link WritableStreamDefaultController.signal}'s `reason` instead.
2217
2225
  */
2218
2226
  get abortReason() {
2219
2227
  if (!IsWritableStreamDefaultController(this)) {
@@ -2267,6 +2275,8 @@
2267
2275
  }
2268
2276
  }
2269
2277
  Object.defineProperties(WritableStreamDefaultController.prototype, {
2278
+ abortReason: { enumerable: true },
2279
+ signal: { enumerable: true },
2270
2280
  error: { enumerable: true }
2271
2281
  });
2272
2282
  if (typeof SymbolPolyfill.toStringTag === 'symbol') {
@@ -3008,6 +3018,7 @@
3008
3018
  function ReadableStreamDefaultTee(stream, cloneForBranch2) {
3009
3019
  const reader = AcquireReadableStreamDefaultReader(stream);
3010
3020
  let reading = false;
3021
+ let readAgain = false;
3011
3022
  let canceled1 = false;
3012
3023
  let canceled2 = false;
3013
3024
  let reason1;
@@ -3020,6 +3031,7 @@
3020
3031
  });
3021
3032
  function pullAlgorithm() {
3022
3033
  if (reading) {
3034
+ readAgain = true;
3023
3035
  return promiseResolvedWith(undefined);
3024
3036
  }
3025
3037
  reading = true;
@@ -3029,7 +3041,7 @@
3029
3041
  // reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
3030
3042
  // successful synchronously-available reads get ahead of asynchronously-available errors.
3031
3043
  queueMicrotask(() => {
3032
- reading = false;
3044
+ readAgain = false;
3033
3045
  const chunk1 = chunk;
3034
3046
  const chunk2 = chunk;
3035
3047
  // There is no way to access the cloning code right now in the reference implementation.
@@ -3043,6 +3055,10 @@
3043
3055
  if (!canceled2) {
3044
3056
  ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, chunk2);
3045
3057
  }
3058
+ reading = false;
3059
+ if (readAgain) {
3060
+ pullAlgorithm();
3061
+ }
3046
3062
  });
3047
3063
  },
3048
3064
  _closeSteps: () => {
@@ -3101,6 +3117,8 @@
3101
3117
  function ReadableByteStreamTee(stream) {
3102
3118
  let reader = AcquireReadableStreamDefaultReader(stream);
3103
3119
  let reading = false;
3120
+ let readAgainForBranch1 = false;
3121
+ let readAgainForBranch2 = false;
3104
3122
  let canceled1 = false;
3105
3123
  let canceled2 = false;
3106
3124
  let reason1;
@@ -3135,7 +3153,8 @@
3135
3153
  // reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
3136
3154
  // successful synchronously-available reads get ahead of asynchronously-available errors.
3137
3155
  queueMicrotask(() => {
3138
- reading = false;
3156
+ readAgainForBranch1 = false;
3157
+ readAgainForBranch2 = false;
3139
3158
  const chunk1 = chunk;
3140
3159
  let chunk2 = chunk;
3141
3160
  if (!canceled1 && !canceled2) {
@@ -3155,6 +3174,13 @@
3155
3174
  if (!canceled2) {
3156
3175
  ReadableByteStreamControllerEnqueue(branch2._readableStreamController, chunk2);
3157
3176
  }
3177
+ reading = false;
3178
+ if (readAgainForBranch1) {
3179
+ pull1Algorithm();
3180
+ }
3181
+ else if (readAgainForBranch2) {
3182
+ pull2Algorithm();
3183
+ }
3158
3184
  });
3159
3185
  },
3160
3186
  _closeSteps: () => {
@@ -3195,7 +3221,8 @@
3195
3221
  // reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
3196
3222
  // successful synchronously-available reads get ahead of asynchronously-available errors.
3197
3223
  queueMicrotask(() => {
3198
- reading = false;
3224
+ readAgainForBranch1 = false;
3225
+ readAgainForBranch2 = false;
3199
3226
  const byobCanceled = forBranch2 ? canceled2 : canceled1;
3200
3227
  const otherCanceled = forBranch2 ? canceled1 : canceled2;
3201
3228
  if (!otherCanceled) {
@@ -3217,6 +3244,13 @@
3217
3244
  else if (!byobCanceled) {
3218
3245
  ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk);
3219
3246
  }
3247
+ reading = false;
3248
+ if (readAgainForBranch1) {
3249
+ pull1Algorithm();
3250
+ }
3251
+ else if (readAgainForBranch2) {
3252
+ pull2Algorithm();
3253
+ }
3220
3254
  });
3221
3255
  },
3222
3256
  _closeSteps: chunk => {
@@ -3249,6 +3283,7 @@
3249
3283
  }
3250
3284
  function pull1Algorithm() {
3251
3285
  if (reading) {
3286
+ readAgainForBranch1 = true;
3252
3287
  return promiseResolvedWith(undefined);
3253
3288
  }
3254
3289
  reading = true;
@@ -3263,6 +3298,7 @@
3263
3298
  }
3264
3299
  function pull2Algorithm() {
3265
3300
  if (reading) {
3301
+ readAgainForBranch2 = true;
3266
3302
  return promiseResolvedWith(undefined);
3267
3303
  }
3268
3304
  reading = true;