@zimic/interceptor 1.1.1-canary.1 → 1.1.2-canary.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/http.mjs CHANGED
@@ -423,7 +423,7 @@ var TimesCheckError = class extends TypeError {
423
423
  };
424
424
  var TimesCheckError_default = TimesCheckError;
425
425
 
426
- // ../zimic-utils/dist/chunk-GUOR4PHC.mjs
426
+ // ../zimic-utils/dist/chunk-F2EXWCVL.mjs
427
427
  async function blobEquals(blob, otherBlob) {
428
428
  if (blob.type !== otherBlob.type || blob.size !== otherBlob.size) {
429
429
  return false;
@@ -434,24 +434,32 @@ async function blobEquals(blob, otherBlob) {
434
434
  let otherBuffer = new Uint8Array(0);
435
435
  try {
436
436
  while (true) {
437
- await Promise.all([
438
- buffer.length === 0 && reader.read().then((result) => {
439
- if (!result.done) {
440
- buffer = result.value;
441
- }
442
- }),
443
- otherBuffer.length === 0 && otherReader.read().then((result) => {
444
- if (!result.done) {
445
- otherBuffer = result.value;
446
- }
447
- })
448
- ]);
449
- const streamsEndedTogether = buffer.length === 0 && otherBuffer.length === 0;
450
- if (streamsEndedTogether) {
437
+ const bufferReadPromises = [];
438
+ if (buffer.length === 0) {
439
+ bufferReadPromises.push(
440
+ reader.read().then((result) => {
441
+ if (!result.done) {
442
+ buffer = result.value;
443
+ }
444
+ })
445
+ );
446
+ }
447
+ if (otherBuffer.length === 0) {
448
+ bufferReadPromises.push(
449
+ otherReader.read().then((result) => {
450
+ if (!result.done) {
451
+ otherBuffer = result.value;
452
+ }
453
+ })
454
+ );
455
+ }
456
+ await Promise.all(bufferReadPromises);
457
+ const haveStreamsEndedTogether = buffer.length === 0 && otherBuffer.length === 0;
458
+ if (haveStreamsEndedTogether) {
451
459
  return true;
452
460
  }
453
- const oneStreamEndedBeforeTheOther = buffer.length === 0 && otherBuffer.length > 0 || buffer.length > 0 && otherBuffer.length === 0;
454
- if (oneStreamEndedBeforeTheOther) {
461
+ const hasOneStreamEndedBeforeTheOther = buffer.length === 0 && otherBuffer.length > 0 || buffer.length > 0 && otherBuffer.length === 0;
462
+ if (hasOneStreamEndedBeforeTheOther) {
455
463
  return false;
456
464
  }
457
465
  const minimumByteLength = Math.min(buffer.length, otherBuffer.length);
@@ -1740,12 +1748,12 @@ var HttpInterceptorClient = class {
1740
1748
  }
1741
1749
  clear(options = {}) {
1742
1750
  const clearResults = [
1743
- this.workerOrThrow.clearInterceptorHandlers(this)
1751
+ Promise.resolve(this.workerOrThrow.clearInterceptorHandlers(this))
1744
1752
  ];
1745
1753
  for (const method of HTTP_METHODS) {
1746
1754
  const newClearResults = this.clearMethodHandlers(method);
1747
1755
  for (const result of newClearResults) {
1748
- clearResults.push(result);
1756
+ clearResults.push(Promise.resolve(result));
1749
1757
  }
1750
1758
  const handlersByPath = this.handlerClientsByMethod[method];
1751
1759
  handlersByPath.clear();