pullfrog 0.1.53 → 0.1.55

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/yes.js CHANGED
@@ -5,11 +5,11 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
9
9
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
10
+ }) : x2)(function(x2) {
11
11
  if (typeof require !== "undefined") return require.apply(this, arguments);
12
- throw Error('Dynamic require of "' + x + '" is not supported');
12
+ throw Error('Dynamic require of "' + x2 + '" is not supported');
13
13
  });
14
14
  var __commonJS = (cb, mod) => function __require2() {
15
15
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
@@ -413,39 +413,38 @@ var require_object_hash = __commonJS({
413
413
  import { performance as performance2 } from "node:perf_hooks";
414
414
  import { setTimeout as sleep } from "node:timers/promises";
415
415
 
416
- // node_modules/.pnpm/lru-cache@11.3.6/node_modules/lru-cache/dist/esm/node/index.min.js
417
- import { tracingChannel as I, channel as G } from "node:diagnostics_channel";
418
- var S = G("lru-cache:metrics");
419
- var W = I("lru-cache");
420
- var C = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
421
- var D = () => S.hasSubscribers || W.hasSubscribers;
416
+ // node_modules/.pnpm/lru-cache@11.5.2/node_modules/lru-cache/dist/esm/node/index.min.js
417
+ import { tracingChannel as G, channel as P } from "node:diagnostics_channel";
418
+ var S = P("lru-cache:metrics");
419
+ var W = G("lru-cache");
420
+ var L = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
421
+ var R = () => S.hasSubscribers || W.hasSubscribers;
422
422
  var U = /* @__PURE__ */ new Set();
423
- var L = typeof process == "object" && process ? process : {};
424
- var P = (u3, e, t, i) => {
425
- typeof L.emitWarning == "function" ? L.emitWarning(u3, e, t, i) : console.error(`[${t}] ${e}: ${u3}`);
423
+ var M = typeof process == "object" && process ? process : {};
424
+ var k = (d3, e, t, i) => {
425
+ typeof M.emitWarning == "function" ? M.emitWarning(d3, e, t, i) : console.error(`[${t}] ${e}: ${d3}`);
426
426
  };
427
- var H = (u3) => !U.has(u3);
428
- var X = Symbol("type");
429
- var F = (u3) => !!u3 && u3 === Math.floor(u3) && u3 > 0 && isFinite(u3);
430
- var j = (u3) => F(u3) ? u3 <= Math.pow(2, 8) ? Uint8Array : u3 <= Math.pow(2, 16) ? Uint16Array : u3 <= Math.pow(2, 32) ? Uint32Array : u3 <= Number.MAX_SAFE_INTEGER ? O : null : null;
427
+ var H = (d3) => !U.has(d3);
428
+ var T = (d3) => !!d3 && d3 === Math.floor(d3) && d3 > 0 && isFinite(d3);
429
+ var j = (d3) => T(d3) ? d3 <= Math.pow(2, 8) ? Uint8Array : d3 <= Math.pow(2, 16) ? Uint16Array : d3 <= Math.pow(2, 32) ? Uint32Array : d3 <= Number.MAX_SAFE_INTEGER ? O : null : null;
431
430
  var O = class extends Array {
432
431
  constructor(e) {
433
432
  super(e), this.fill(0);
434
433
  }
435
434
  };
436
- var R = class u {
435
+ var x = class d {
437
436
  heap;
438
437
  length;
439
438
  static #o = false;
440
439
  static create(e) {
441
440
  let t = j(e);
442
441
  if (!t) return [];
443
- u.#o = true;
444
- let i = new u(e, t);
445
- return u.#o = false, i;
442
+ d.#o = true;
443
+ let i = new d(e, t);
444
+ return d.#o = false, i;
446
445
  }
447
446
  constructor(e, t) {
448
- if (!u.#o) throw new TypeError("instantiate Stack using Stack.create(n)");
447
+ if (!d.#o) throw new TypeError("instantiate Stack using Stack.create(n)");
449
448
  this.heap = new t(e), this.length = 0;
450
449
  }
451
450
  push(e) {
@@ -455,14 +454,14 @@ var R = class u {
455
454
  return this.heap[--this.length];
456
455
  }
457
456
  };
458
- var M = class u2 {
457
+ var I = class d2 {
459
458
  #o;
460
- #u;
461
- #w;
462
- #x;
459
+ #c;
463
460
  #S;
461
+ #O;
462
+ #w;
464
463
  #M;
465
- #U;
464
+ #I;
466
465
  #m;
467
466
  get perf() {
468
467
  return this.#m;
@@ -482,14 +481,15 @@ var M = class u2 {
482
481
  allowStaleOnFetchAbort;
483
482
  allowStaleOnFetchRejection;
484
483
  ignoreFetchAbort;
484
+ backgroundFetchSize;
485
485
  #n;
486
486
  #b;
487
487
  #s;
488
488
  #i;
489
489
  #t;
490
- #a;
491
- #c;
492
490
  #l;
491
+ #u;
492
+ #a;
493
493
  #h;
494
494
  #y;
495
495
  #r;
@@ -498,12 +498,12 @@ var M = class u2 {
498
498
  #d;
499
499
  #g;
500
500
  #T;
501
- #W;
501
+ #U;
502
502
  #f;
503
- #j;
503
+ #D;
504
504
  static unsafeExposeInternals(e) {
505
- return { starts: e.#F, ttls: e.#d, autopurgeTimers: e.#g, sizes: e.#_, keyMap: e.#s, keyList: e.#i, valList: e.#t, next: e.#a, prev: e.#c, get head() {
506
- return e.#l;
505
+ return { starts: e.#F, ttls: e.#d, autopurgeTimers: e.#g, sizes: e.#_, keyMap: e.#s, keyList: e.#i, valList: e.#t, next: e.#l, prev: e.#u, get head() {
506
+ return e.#a;
507
507
  }, get tail() {
508
508
  return e.#h;
509
509
  }, free: e.#y, isBackgroundFetch: (t) => e.#e(t), backgroundFetch: (t, i, s, n) => e.#P(t, i, s, n), moveToTail: (t) => e.#L(t), indexes: (t) => e.#A(t), rindexes: (t) => e.#z(t), isStale: (t) => e.#p(t) };
@@ -512,7 +512,7 @@ var M = class u2 {
512
512
  return this.#o;
513
513
  }
514
514
  get maxSize() {
515
- return this.#u;
515
+ return this.#c;
516
516
  }
517
517
  get calculatedSize() {
518
518
  return this.#b;
@@ -524,134 +524,139 @@ var M = class u2 {
524
524
  return this.#M;
525
525
  }
526
526
  get memoMethod() {
527
- return this.#U;
527
+ return this.#I;
528
528
  }
529
529
  get dispose() {
530
- return this.#w;
530
+ return this.#S;
531
531
  }
532
532
  get onInsert() {
533
- return this.#x;
533
+ return this.#O;
534
534
  }
535
535
  get disposeAfter() {
536
- return this.#S;
536
+ return this.#w;
537
537
  }
538
538
  constructor(e) {
539
- let { max: t = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: r, allowStale: h, dispose: l, onInsert: c, disposeAfter: f, noDisposeOnSet: g, noUpdateTTL: p, maxSize: T = 0, maxEntrySize: w = 0, sizeCalculation: y, fetchMethod: a, memoMethod: m, noDeleteOnFetchRejection: _, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: d, allowStaleOnFetchAbort: A, ignoreFetchAbort: z, perf: x } = e;
540
- if (x !== void 0 && typeof x?.now != "function") throw new TypeError("perf option must have a now() method if specified");
541
- if (this.#m = x ?? C, t !== 0 && !F(t)) throw new TypeError("max option must be a nonnegative integer");
539
+ let { max: t = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: l, allowStale: h, dispose: r, onInsert: c, disposeAfter: m, noDisposeOnSet: _, noUpdateTTL: u, maxSize: g = 0, maxEntrySize: f = 0, sizeCalculation: y, fetchMethod: a, memoMethod: w, noDeleteOnFetchRejection: F, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: p, allowStaleOnFetchAbort: A, ignoreFetchAbort: z, backgroundFetchSize: C = 1, perf: E } = e;
540
+ if (this.backgroundFetchSize = C, E !== void 0 && typeof E?.now != "function") throw new TypeError("perf option must have a now() method if specified");
541
+ if (this.#m = E ?? L, t !== 0 && !T(t)) throw new TypeError("max option must be a nonnegative integer");
542
542
  let v = t ? j(t) : Array;
543
543
  if (!v) throw new Error("invalid max value: " + t);
544
- if (this.#o = t, this.#u = T, this.maxEntrySize = w || this.#u, this.sizeCalculation = y, this.sizeCalculation) {
545
- if (!this.#u && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
544
+ if (this.#o = t, this.#c = g, this.maxEntrySize = f || this.#c, this.sizeCalculation = y, this.sizeCalculation) {
545
+ if (!this.#c && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
546
546
  if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
547
547
  }
548
- if (m !== void 0 && typeof m != "function") throw new TypeError("memoMethod must be a function if defined");
549
- if (this.#U = m, a !== void 0 && typeof a != "function") throw new TypeError("fetchMethod must be a function if specified");
550
- if (this.#M = a, this.#W = !!a, this.#s = /* @__PURE__ */ new Map(), this.#i = Array.from({ length: t }).fill(void 0), this.#t = Array.from({ length: t }).fill(void 0), this.#a = new v(t), this.#c = new v(t), this.#l = 0, this.#h = 0, this.#y = R.create(t), this.#n = 0, this.#b = 0, typeof l == "function" && (this.#w = l), typeof c == "function" && (this.#x = c), typeof f == "function" ? (this.#S = f, this.#r = []) : (this.#S = void 0, this.#r = void 0), this.#T = !!this.#w, this.#j = !!this.#x, this.#f = !!this.#S, this.noDisposeOnSet = !!g, this.noUpdateTTL = !!p, this.noDeleteOnFetchRejection = !!_, this.allowStaleOnFetchRejection = !!d, this.allowStaleOnFetchAbort = !!A, this.ignoreFetchAbort = !!z, this.maxEntrySize !== 0) {
551
- if (this.#u !== 0 && !F(this.#u)) throw new TypeError("maxSize must be a positive integer if specified");
552
- if (!F(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
548
+ if (w !== void 0 && typeof w != "function") throw new TypeError("memoMethod must be a function if defined");
549
+ if (this.#I = w, a !== void 0 && typeof a != "function") throw new TypeError("fetchMethod must be a function if specified");
550
+ if (this.#M = a, this.#U = !!a, this.#s = /* @__PURE__ */ new Map(), this.#i = Array.from({ length: t }).fill(void 0), this.#t = Array.from({ length: t }).fill(void 0), this.#l = new v(t), this.#u = new v(t), this.#a = 0, this.#h = 0, this.#y = x.create(t), this.#n = 0, this.#b = 0, typeof r == "function" && (this.#S = r), typeof c == "function" && (this.#O = c), typeof m == "function" ? (this.#w = m, this.#r = []) : (this.#w = void 0, this.#r = void 0), this.#T = !!this.#S, this.#D = !!this.#O, this.#f = !!this.#w, this.noDisposeOnSet = !!_, this.noUpdateTTL = !!u, this.noDeleteOnFetchRejection = !!F, this.allowStaleOnFetchRejection = !!p, this.allowStaleOnFetchAbort = !!A, this.ignoreFetchAbort = !!z, this.maxEntrySize !== 0) {
551
+ if (this.#c !== 0 && !T(this.#c)) throw new TypeError("maxSize must be a positive integer if specified");
552
+ if (!T(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
553
553
  this.#X();
554
554
  }
555
- if (this.allowStale = !!h, this.noDeleteOnStaleGet = !!b, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!r, this.ttlResolution = F(s) || s === 0 ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
556
- if (!F(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
557
- this.#H();
555
+ if (this.allowStale = !!h, this.noDeleteOnStaleGet = !!b, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!l, this.ttlResolution = T(s) || s === 0 ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
556
+ if (!T(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
557
+ this.#k();
558
558
  }
559
- if (this.#o === 0 && this.ttl === 0 && this.#u === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
560
- if (!this.ttlAutopurge && !this.#o && !this.#u) {
561
- let E = "LRU_CACHE_UNBOUNDED";
562
- H(E) && (U.add(E), P("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", E, u2));
559
+ if (this.#o === 0 && this.ttl === 0 && this.#c === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
560
+ if (!this.ttlAutopurge && !this.#o && !this.#c) {
561
+ let D = "LRU_CACHE_UNBOUNDED";
562
+ H(D) && (U.add(D), k("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", D, d2));
563
563
  }
564
564
  }
565
565
  getRemainingTTL(e) {
566
566
  return this.#s.has(e) ? 1 / 0 : 0;
567
567
  }
568
- #H() {
568
+ #k() {
569
569
  let e = new O(this.#o), t = new O(this.#o);
570
570
  this.#d = e, this.#F = t;
571
571
  let i = this.ttlAutopurge ? Array.from({ length: this.#o }) : void 0;
572
- this.#g = i, this.#N = (r, h, l = this.#m.now()) => {
573
- t[r] = h !== 0 ? l : 0, e[r] = h, s(r, h);
574
- }, this.#D = (r) => {
575
- t[r] = e[r] !== 0 ? this.#m.now() : 0, s(r, e[r]);
572
+ this.#g = i, this.#H = (h, r, c = this.#m.now()) => {
573
+ t[h] = r !== 0 ? c : 0, e[h] = r, s(h, r);
574
+ }, this.#R = (h) => {
575
+ t[h] = e[h] !== 0 ? this.#m.now() : 0, s(h, e[h]);
576
576
  };
577
- let s = this.ttlAutopurge ? (r, h) => {
578
- if (i?.[r] && (clearTimeout(i[r]), i[r] = void 0), h && h !== 0 && i) {
579
- let l = setTimeout(() => {
580
- this.#p(r) && this.#v(this.#i[r], "expire");
581
- }, h + 1);
582
- l.unref && l.unref(), i[r] = l;
577
+ let s = this.ttlAutopurge ? (h, r) => {
578
+ if (i?.[h] && (clearTimeout(i[h]), i[h] = void 0), r && r !== 0 && i) {
579
+ let c = setTimeout(() => {
580
+ this.#p(h) ? (this.#E(this.#i[h], "expire"), i[h] = void 0) : s(h, l(h));
581
+ }, r + 1);
582
+ c.unref && c.unref(), i[h] = c;
583
583
  }
584
584
  } : () => {
585
585
  };
586
- this.#E = (r, h) => {
587
- if (e[h]) {
588
- let l = e[h], c = t[h];
589
- if (!l || !c) return;
590
- r.ttl = l, r.start = c, r.now = n || o();
591
- let f = r.now - c;
592
- r.remainingTTL = l - f;
586
+ this.#v = (h, r) => {
587
+ if (e[r]) {
588
+ let c = e[r], m = t[r];
589
+ if (!c || !m) return;
590
+ h.ttl = c, h.start = m, h.now = n || o();
591
+ let _ = h.now - m;
592
+ h.remainingTTL = c - _;
593
593
  }
594
594
  };
595
595
  let n = 0, o = () => {
596
- let r = this.#m.now();
596
+ let h = this.#m.now();
597
597
  if (this.ttlResolution > 0) {
598
- n = r;
599
- let h = setTimeout(() => n = 0, this.ttlResolution);
600
- h.unref && h.unref();
598
+ n = h;
599
+ let r = setTimeout(() => n = 0, this.ttlResolution);
600
+ r.unref && r.unref();
601
601
  }
602
- return r;
602
+ return h;
603
+ };
604
+ this.getRemainingTTL = (h) => {
605
+ let r = this.#s.get(h);
606
+ return r === void 0 ? 0 : l(r);
603
607
  };
604
- this.getRemainingTTL = (r) => {
605
- let h = this.#s.get(r);
606
- if (h === void 0) return 0;
607
- let l = e[h], c = t[h];
608
- if (!l || !c) return 1 / 0;
609
- let f = (n || o()) - c;
610
- return l - f;
611
- }, this.#p = (r) => {
612
- let h = t[r], l = e[r];
613
- return !!l && !!h && (n || o()) - h > l;
608
+ let l = (h) => {
609
+ let r = e[h], c = t[h];
610
+ if (!r || !c) return 1 / 0;
611
+ let m = (n || o()) - c;
612
+ return r - m;
613
+ };
614
+ this.#p = (h) => {
615
+ let r = t[h], c = e[h];
616
+ return !!c && !!r && (n || o()) - r > c;
614
617
  };
615
618
  }
616
- #D = () => {
619
+ #R = () => {
617
620
  };
618
- #E = () => {
621
+ #v = () => {
619
622
  };
620
- #N = () => {
623
+ #H = () => {
621
624
  };
622
625
  #p = () => false;
623
626
  #X() {
624
627
  let e = new O(this.#o);
625
- this.#b = 0, this.#_ = e, this.#R = (t) => {
628
+ this.#b = 0, this.#_ = e, this.#x = (t) => {
626
629
  this.#b -= e[t], e[t] = 0;
627
- }, this.#k = (t, i, s, n) => {
628
- if (this.#e(i)) return 0;
629
- if (!F(s)) if (n) {
630
- if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
631
- if (s = n(i, t), !F(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
632
- } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
630
+ }, this.#N = (t, i, s, n) => {
631
+ if (!T(s)) {
632
+ if (this.#e(i)) return this.backgroundFetchSize;
633
+ if (n) {
634
+ if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
635
+ if (s = n(i, t), !T(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
636
+ } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
637
+ }
633
638
  return s;
634
- }, this.#I = (t, i, s) => {
635
- if (e[t] = i, this.#u) {
636
- let n = this.#u - e[t];
639
+ }, this.#j = (t, i, s) => {
640
+ if (e[t] = i, this.#c) {
641
+ let n = this.#c - e[t];
637
642
  for (; this.#b > n; ) this.#G(true);
638
643
  }
639
644
  this.#b += e[t], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
640
645
  };
641
646
  }
642
- #R = (e) => {
647
+ #x = (e) => {
643
648
  };
644
- #I = (e, t, i) => {
649
+ #j = (e, t, i) => {
645
650
  };
646
- #k = (e, t, i, s) => {
651
+ #N = (e, t, i, s) => {
647
652
  if (i || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
648
653
  return 0;
649
654
  };
650
655
  *#A({ allowStale: e = this.allowStale } = {}) {
651
- if (this.#n) for (let t = this.#h; this.#V(t) && ((e || !this.#p(t)) && (yield t), t !== this.#l); ) t = this.#c[t];
656
+ if (this.#n) for (let t = this.#h; this.#V(t) && ((e || !this.#p(t)) && (yield t), t !== this.#a); ) t = this.#u[t];
652
657
  }
653
658
  *#z({ allowStale: e = this.allowStale } = {}) {
654
- if (this.#n) for (let t = this.#l; this.#V(t) && ((e || !this.#p(t)) && (yield t), t !== this.#h); ) t = this.#a[t];
659
+ if (this.#n) for (let t = this.#a; this.#V(t) && ((e || !this.#p(t)) && (yield t), t !== this.#h); ) t = this.#l[t];
655
660
  }
656
661
  #V(e) {
657
662
  return e !== void 0 && this.#s.get(this.#i[e]) === e;
@@ -704,7 +709,7 @@ var M = class u2 {
704
709
  }
705
710
  purgeStale() {
706
711
  let e = false;
707
- for (let t of this.#z({ allowStale: true })) this.#p(t) && (this.#v(this.#i[t], "expire"), e = true);
712
+ for (let t of this.#z({ allowStale: true })) this.#p(t) && (this.#E(this.#i[t], "expire"), e = true);
708
713
  return e;
709
714
  }
710
715
  info(e) {
@@ -714,9 +719,9 @@ var M = class u2 {
714
719
  if (s === void 0) return;
715
720
  let n = { value: s };
716
721
  if (this.#d && this.#F) {
717
- let o = this.#d[t], r = this.#F[t];
718
- if (o && r) {
719
- let h = o - (this.#m.now() - r);
722
+ let o = this.#d[t], l = this.#F[t];
723
+ if (o && l) {
724
+ let h = o - (this.#m.now() - l);
720
725
  n.ttl = h, n.start = Date.now();
721
726
  }
722
727
  }
@@ -730,8 +735,8 @@ var M = class u2 {
730
735
  let o = { value: n };
731
736
  if (this.#d && this.#F) {
732
737
  o.ttl = this.#d[t];
733
- let r = this.#m.now() - this.#F[t];
734
- o.start = Math.floor(Date.now() - r);
738
+ let l = this.#m.now() - this.#F[t];
739
+ o.start = Math.floor(Date.now() - l);
735
740
  }
736
741
  this.#_ && (o.size = this.#_[t]), e.unshift([i, o]);
737
742
  }
@@ -744,51 +749,49 @@ var M = class u2 {
744
749
  let s = Date.now() - i.start;
745
750
  i.start = this.#m.now() - s;
746
751
  }
747
- this.#O(t, i.value, i);
752
+ this.#W(t, i.value, i);
748
753
  }
749
754
  }
750
755
  set(e, t, i = {}) {
751
756
  let { status: s = S.hasSubscribers ? {} : void 0 } = i;
752
- i.status = s, s && (s.op = "set", s.key = e, t !== void 0 && (s.value = t));
753
- let n = this.#O(e, t, i);
757
+ i.status = s, s && (s.op = "set", s.key = e, t !== void 0 && (s.value = t), s.cache = this);
758
+ let n = this.#W(e, t, i);
754
759
  return s && S.hasSubscribers && S.publish(s), n;
755
760
  }
756
- #O(e, t, i = {}) {
757
- let { ttl: s = this.ttl, start: n, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: r = this.sizeCalculation, status: h } = i;
758
- if (t === void 0) return h && (h.set = "deleted"), this.delete(e), this;
759
- let { noUpdateTTL: l = this.noUpdateTTL } = i;
760
- h && !this.#e(t) && (h.value = t);
761
- let c = this.#k(e, t, i.size || 0, r, h);
762
- if (this.maxEntrySize && c > this.maxEntrySize) return this.#v(e, "set"), h && (h.set = "miss", h.maxEntrySizeExceeded = true), this;
763
- let f = this.#n === 0 ? void 0 : this.#s.get(e);
764
- if (f === void 0) f = this.#n === 0 ? this.#h : this.#y.length !== 0 ? this.#y.pop() : this.#n === this.#o ? this.#G(false) : this.#n, this.#i[f] = e, this.#t[f] = t, this.#s.set(e, f), this.#a[this.#h] = f, this.#c[f] = this.#h, this.#h = f, this.#n++, this.#I(f, c, h), h && (h.set = "add"), l = false, this.#j && this.#x?.(t, e, "add");
761
+ #W(e, t, i, s) {
762
+ let { ttl: n = this.ttl, start: o, noDisposeOnSet: l = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: r } = i, c = this.#e(t);
763
+ if (t === void 0) return r && (r.set = "deleted"), this.delete(e), this;
764
+ let { noUpdateTTL: m = this.noUpdateTTL } = i;
765
+ r && !c && (r.value = t);
766
+ let _ = this.#N(e, t, i.size || 0, h, r);
767
+ if (this.maxEntrySize && _ > this.maxEntrySize) return this.#E(e, "set"), r && (r.set = "miss", r.maxEntrySizeExceeded = true), this;
768
+ let u = this.#n === 0 ? void 0 : this.#s.get(e);
769
+ if (u === void 0) u = this.#n === 0 ? this.#h : this.#y.length !== 0 ? this.#y.pop() : this.#n === this.#o ? this.#G(false) : this.#n, this.#i[u] = e, this.#t[u] = t, this.#s.set(e, u), this.#l[this.#h] = u, this.#u[u] = this.#h, this.#h = u, this.#n++, this.#j(u, _, r), r && (r.set = "add"), m = false, this.#D && !c && this.#O?.(t, e, "add");
765
770
  else {
766
- this.#L(f);
767
- let g = this.#t[f];
771
+ this.#L(u);
772
+ let g = this.#t[u];
768
773
  if (t !== g) {
769
- if (this.#W && this.#e(g)) {
770
- g.__abortController.abort(new Error("replaced"));
771
- let { __staleWhileFetching: p } = g;
772
- p !== void 0 && !o && (this.#T && this.#w?.(p, e, "set"), this.#f && this.#r?.push([p, e, "set"]));
773
- } else o || (this.#T && this.#w?.(g, e, "set"), this.#f && this.#r?.push([g, e, "set"]));
774
- if (this.#R(f), this.#I(f, c, h), this.#t[f] = t, h) {
775
- h.set = "replace";
776
- let p = g && this.#e(g) ? g.__staleWhileFetching : g;
777
- p !== void 0 && (h.oldValue = p);
774
+ if (!l) if (this.#e(g)) {
775
+ g !== s && g.__abortController.abort(new Error("replaced"));
776
+ let { __staleWhileFetching: f } = g;
777
+ f !== void 0 && f !== t && (this.#T && this.#S?.(f, e, "set"), this.#f && this.#r?.push([f, e, "set"]));
778
+ } else this.#T && this.#S?.(g, e, "set"), this.#f && this.#r?.push([g, e, "set"]);
779
+ if (this.#x(u), this.#j(u, _, r), this.#t[u] = t, !c) {
780
+ let f = g && this.#e(g) ? g.__staleWhileFetching : g, y = f === void 0 ? "add" : t !== f ? "replace" : "update";
781
+ r && (r.set = y, f !== void 0 && (r.oldValue = f)), this.#D && this.onInsert?.(t, e, y);
778
782
  }
779
- } else h && (h.set = "update");
780
- this.#j && this.onInsert?.(t, e, t === g ? "update" : "replace");
783
+ } else c || (r && (r.set = "update"), this.#D && this.onInsert?.(t, e, "update"));
781
784
  }
782
- if (s !== 0 && !this.#d && this.#H(), this.#d && (l || this.#N(f, s, n), h && this.#E(h, f)), !o && this.#f && this.#r) {
783
- let g = this.#r, p;
784
- for (; p = g?.shift(); ) this.#S?.(...p);
785
+ if (n !== 0 && !this.#d && this.#k(), this.#d && (m || this.#H(u, n, o), r && this.#v(r, u)), !l && this.#f && this.#r) {
786
+ let g = this.#r, f;
787
+ for (; f = g?.shift(); ) this.#w?.(...f);
785
788
  }
786
789
  return this;
787
790
  }
788
791
  pop() {
789
792
  try {
790
793
  for (; this.#n; ) {
791
- let e = this.#t[this.#l];
794
+ let e = this.#t[this.#a];
792
795
  if (this.#G(true), this.#e(e)) {
793
796
  if (e.__staleWhileFetching) return e.__staleWhileFetching;
794
797
  } else if (e !== void 0) return e;
@@ -796,17 +799,19 @@ var M = class u2 {
796
799
  } finally {
797
800
  if (this.#f && this.#r) {
798
801
  let e = this.#r, t;
799
- for (; t = e?.shift(); ) this.#S?.(...t);
802
+ for (; t = e?.shift(); ) this.#w?.(...t);
800
803
  }
801
804
  }
802
805
  }
803
806
  #G(e) {
804
- let t = this.#l, i = this.#i[t], s = this.#t[t];
805
- return this.#W && this.#e(s) ? s.__abortController.abort(new Error("evicted")) : (this.#T || this.#f) && (this.#T && this.#w?.(s, i, "evict"), this.#f && this.#r?.push([s, i, "evict"])), this.#R(t), this.#g?.[t] && (clearTimeout(this.#g[t]), this.#g[t] = void 0), e && (this.#i[t] = void 0, this.#t[t] = void 0, this.#y.push(t)), this.#n === 1 ? (this.#l = this.#h = 0, this.#y.length = 0) : this.#l = this.#a[t], this.#s.delete(i), this.#n--, t;
807
+ let t = this.#a, i = this.#i[t], s = this.#t[t], n = this.#e(s);
808
+ n && s.__abortController.abort(new Error("evicted"));
809
+ let o = n ? s.__staleWhileFetching : s;
810
+ return (this.#T || this.#f) && o !== void 0 && (this.#T && this.#S?.(o, i, "evict"), this.#f && this.#r?.push([o, i, "evict"])), this.#x(t), this.#g?.[t] && (clearTimeout(this.#g[t]), this.#g[t] = void 0), e && (this.#i[t] = void 0, this.#t[t] = void 0, this.#y.push(t)), this.#n === 1 ? (this.#a = this.#h = 0, this.#y.length = 0) : this.#a = this.#l[t], this.#s.delete(i), this.#n--, t;
806
811
  }
807
812
  has(e, t = {}) {
808
813
  let { status: i = S.hasSubscribers ? {} : void 0 } = t;
809
- t.status = i, i && (i.op = "has", i.key = e);
814
+ t.status = i, i && (i.op = "has", i.key = e, i.cache = this);
810
815
  let s = this.#Y(e, t);
811
816
  return S.hasSubscribers && S.publish(i), s;
812
817
  }
@@ -815,14 +820,14 @@ var M = class u2 {
815
820
  if (n !== void 0) {
816
821
  let o = this.#t[n];
817
822
  if (this.#e(o) && o.__staleWhileFetching === void 0) return false;
818
- if (this.#p(n)) s && (s.has = "stale", this.#E(s, n));
819
- else return i && this.#D(n), s && (s.has = "hit", this.#E(s, n)), true;
823
+ if (this.#p(n)) s && (s.has = "stale", this.#v(s, n));
824
+ else return i && this.#R(n), s && (s.has = "hit", this.#v(s, n)), true;
820
825
  } else s && (s.has = "miss");
821
826
  return false;
822
827
  }
823
828
  peek(e, t = {}) {
824
- let { status: i = D() ? {} : void 0 } = t;
825
- i && (i.op = "peek", i.key = e), t.status = i;
829
+ let { status: i = R() ? {} : void 0 } = t;
830
+ i && (i.op = "peek", i.key = e, i.cache = this), t.status = i;
826
831
  let s = this.#J(e, t);
827
832
  return S.hasSubscribers && S.publish(i), s;
828
833
  }
@@ -832,67 +837,67 @@ var M = class u2 {
832
837
  i && (i.peek = n === void 0 ? "miss" : "stale");
833
838
  return;
834
839
  }
835
- let o = this.#t[n], r = this.#e(o) ? o.__staleWhileFetching : o;
836
- return i && (r !== void 0 ? (i.peek = "hit", i.value = r) : i.peek = "miss"), r;
840
+ let o = this.#t[n], l = this.#e(o) ? o.__staleWhileFetching : o;
841
+ return i && (l !== void 0 ? (i.peek = "hit", i.value = l) : i.peek = "miss"), l;
837
842
  }
838
843
  #P(e, t, i, s) {
839
844
  let n = t === void 0 ? void 0 : this.#t[t];
840
845
  if (this.#e(n)) return n;
841
- let o = new AbortController(), { signal: r } = i;
842
- r?.addEventListener("abort", () => o.abort(r.reason), { signal: o.signal });
843
- let h = { signal: o.signal, options: i, context: s }, l = (w, y = false) => {
844
- let { aborted: a } = o.signal, m = i.ignoreFetchAbort && w !== void 0, _ = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && w !== void 0);
845
- if (i.status && (a && !y ? (i.status.fetchAborted = true, i.status.fetchError = o.signal.reason, m && (i.status.fetchAbortIgnored = true)) : i.status.fetchResolved = true), a && !m && !y) return f(o.signal.reason, _);
846
- let b = p, d = this.#t[t];
847
- return (d === p || d === void 0 && m && y) && (w === void 0 ? b.__staleWhileFetching !== void 0 ? this.#t[t] = b.__staleWhileFetching : this.#v(e, "fetch") : (i.status && (i.status.fetchUpdated = true), this.#O(e, w, h.options))), w;
848
- }, c = (w) => (i.status && (i.status.fetchRejected = true, i.status.fetchError = w), f(w, false)), f = (w, y) => {
849
- let { aborted: a } = o.signal, m = a && i.allowStaleOnFetchAbort, _ = m || i.allowStaleOnFetchRejection, b = _ || i.noDeleteOnFetchRejection, d = p;
850
- if (this.#t[t] === p && (!b || !y && d.__staleWhileFetching === void 0 ? this.#v(e, "fetch") : m || (this.#t[t] = d.__staleWhileFetching)), _) return i.status && d.__staleWhileFetching !== void 0 && (i.status.returnedStale = true), d.__staleWhileFetching;
851
- if (d.__returned === d) throw w;
852
- }, g = (w, y) => {
846
+ let o = new AbortController(), { signal: l } = i;
847
+ l?.addEventListener("abort", () => o.abort(l.reason), { signal: o.signal });
848
+ let h = { signal: o.signal, options: i, context: s }, r = (f, y = false) => {
849
+ let { aborted: a } = o.signal, w = i.ignoreFetchAbort && f !== void 0, F = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && f !== void 0);
850
+ if (i.status && (a && !y ? (i.status.fetchAborted = true, i.status.fetchError = o.signal.reason, w && (i.status.fetchAbortIgnored = true)) : i.status.fetchResolved = true), a && !w && !y) return m(o.signal.reason, F);
851
+ let b = u, p = this.#t[t];
852
+ return (p === u || p === void 0 && w && y) && (f === void 0 ? b.__staleWhileFetching !== void 0 ? this.#t[t] = b.__staleWhileFetching : this.#E(e, "fetch") : (i.status && (i.status.fetchUpdated = true), this.#W(e, f, h.options, b))), f;
853
+ }, c = (f) => (i.status && (i.status.fetchRejected = true, i.status.fetchError = f), m(f, false)), m = (f, y) => {
854
+ let { aborted: a } = o.signal, w = a && i.allowStaleOnFetchAbort, F = w || i.allowStaleOnFetchRejection, b = F || i.noDeleteOnFetchRejection, p = u;
855
+ if (this.#t[t] === u && (!b || !y && p.__staleWhileFetching === void 0 ? this.#E(e, "fetch") : w || (this.#t[t] = p.__staleWhileFetching)), F) return i.status && p.__staleWhileFetching !== void 0 && (i.status.returnedStale = true), p.__staleWhileFetching;
856
+ if (p.__returned === p) throw f;
857
+ }, _ = (f, y) => {
853
858
  let a = this.#M?.(e, n, h);
854
- a && a instanceof Promise && a.then((m) => w(m === void 0 ? void 0 : m), y), o.signal.addEventListener("abort", () => {
855
- (!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (w(void 0), i.allowStaleOnFetchAbort && (w = (m) => l(m, true)));
856
- });
859
+ o.signal.addEventListener("abort", () => {
860
+ (!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (f(void 0), i.allowStaleOnFetchAbort && (f = (w) => r(w, true)));
861
+ }), a && a instanceof Promise ? a.then((w) => f(w === void 0 ? void 0 : w), y) : a !== void 0 && f(a);
857
862
  };
858
863
  i.status && (i.status.fetchDispatched = true);
859
- let p = new Promise(g).then(l, c), T = Object.assign(p, { __abortController: o, __staleWhileFetching: n, __returned: void 0 });
860
- return t === void 0 ? (this.#O(e, T, { ...h.options, status: void 0 }), t = this.#s.get(e)) : this.#t[t] = T, T;
864
+ let u = new Promise(_).then(r, c), g = Object.assign(u, { __abortController: o, __staleWhileFetching: n, __returned: void 0 });
865
+ return t === void 0 ? (this.#W(e, g, { ...h.options, status: void 0 }), t = this.#s.get(e)) : this.#t[t] = g, g;
861
866
  }
862
867
  #e(e) {
863
- if (!this.#W) return false;
868
+ if (!this.#U) return false;
864
869
  let t = e;
865
870
  return !!t && t instanceof Promise && t.hasOwnProperty("__staleWhileFetching") && t.__abortController instanceof AbortController;
866
871
  }
867
872
  fetch(e, t = {}) {
868
- let i = W.hasSubscribers, { status: s = D() ? {} : void 0 } = t;
873
+ let i = W.hasSubscribers, { status: s = R() ? {} : void 0 } = t;
869
874
  t.status = s, s && t.context && (s.context = t.context);
870
875
  let n = this.#B(e, t);
871
876
  return s && i && (s.trace = true, W.tracePromise(() => n, s).catch(() => {
872
877
  })), n;
873
878
  }
874
879
  async #B(e, t = {}) {
875
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: r = this.noDisposeOnSet, size: h = 0, sizeCalculation: l = this.sizeCalculation, noUpdateTTL: c = this.noUpdateTTL, noDeleteOnFetchRejection: f = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: g = this.allowStaleOnFetchRejection, ignoreFetchAbort: p = this.ignoreFetchAbort, allowStaleOnFetchAbort: T = this.allowStaleOnFetchAbort, context: w, forceRefresh: y = false, status: a, signal: m } = t;
876
- if (a && (a.op = "fetch", a.key = e, y && (a.forceRefresh = true)), !this.#W) return a && (a.fetch = "get"), this.#C(e, { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, status: a });
877
- let _ = { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, ttl: o, noDisposeOnSet: r, size: h, sizeCalculation: l, noUpdateTTL: c, noDeleteOnFetchRejection: f, allowStaleOnFetchRejection: g, allowStaleOnFetchAbort: T, ignoreFetchAbort: p, status: a, signal: m }, b = this.#s.get(e);
880
+ let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: l = this.noDisposeOnSet, size: h = 0, sizeCalculation: r = this.sizeCalculation, noUpdateTTL: c = this.noUpdateTTL, noDeleteOnFetchRejection: m = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: _ = this.allowStaleOnFetchRejection, ignoreFetchAbort: u = this.ignoreFetchAbort, allowStaleOnFetchAbort: g = this.allowStaleOnFetchAbort, context: f, forceRefresh: y = false, status: a, signal: w } = t;
881
+ if (a && (a.op = "fetch", a.key = e, y && (a.forceRefresh = true), a.cache = this), !this.#U) return a && (a.fetch = "get"), this.#C(e, { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, status: a });
882
+ let F = { allowStale: i, updateAgeOnGet: s, noDeleteOnStaleGet: n, ttl: o, noDisposeOnSet: l, size: h, sizeCalculation: r, noUpdateTTL: c, noDeleteOnFetchRejection: m, allowStaleOnFetchRejection: _, allowStaleOnFetchAbort: g, ignoreFetchAbort: u, status: a, signal: w }, b = this.#s.get(e);
878
883
  if (b === void 0) {
879
884
  a && (a.fetch = "miss");
880
- let d = this.#P(e, b, _, w);
881
- return d.__returned = d;
885
+ let p = this.#P(e, b, F, f);
886
+ return p.__returned = p;
882
887
  } else {
883
- let d = this.#t[b];
884
- if (this.#e(d)) {
885
- let E = i && d.__staleWhileFetching !== void 0;
886
- return a && (a.fetch = "inflight", E && (a.returnedStale = true)), E ? d.__staleWhileFetching : d.__returned = d;
888
+ let p = this.#t[b];
889
+ if (this.#e(p)) {
890
+ let v = i && p.__staleWhileFetching !== void 0;
891
+ return a && (a.fetch = "inflight", v && (a.returnedStale = true)), v ? p.__staleWhileFetching : p.__returned = p;
887
892
  }
888
893
  let A = this.#p(b);
889
- if (!y && !A) return a && (a.fetch = "hit"), this.#L(b), s && this.#D(b), a && this.#E(a, b), d;
890
- let z = this.#P(e, b, _, w), v = z.__staleWhileFetching !== void 0 && i;
891
- return a && (a.fetch = A ? "stale" : "refresh", v && A && (a.returnedStale = true)), v ? z.__staleWhileFetching : z.__returned = z;
894
+ if (!y && !A) return a && (a.fetch = "hit"), this.#L(b), s && this.#R(b), a && this.#v(a, b), p;
895
+ let z = this.#P(e, b, F, f), E = z.__staleWhileFetching !== void 0 && i;
896
+ return a && (a.fetch = A ? "stale" : "refresh", E && A && (a.returnedStale = true)), E ? z.__staleWhileFetching : z.__returned = z;
892
897
  }
893
898
  }
894
899
  forceFetch(e, t = {}) {
895
- let i = W.hasSubscribers, { status: s = D() ? {} : void 0 } = t;
900
+ let i = W.hasSubscribers, { status: s = R() ? {} : void 0 } = t;
896
901
  t.status = s, s && t.context && (s.context = t.context);
897
902
  let n = this.#K(e, t);
898
903
  return s && i && (s.trace = true, W.tracePromise(() => n, s).catch(() => {
@@ -905,67 +910,67 @@ var M = class u2 {
905
910
  }
906
911
  memo(e, t = {}) {
907
912
  let { status: i = S.hasSubscribers ? {} : void 0 } = t;
908
- t.status = i, i && (i.op = "memo", i.key = e, t.context && (i.context = t.context));
913
+ t.status = i, i && (i.op = "memo", i.key = e, t.context && (i.context = t.context), i.cache = this);
909
914
  let s = this.#Q(e, t);
910
915
  return i && (i.value = s), S.hasSubscribers && S.publish(i), s;
911
916
  }
912
917
  #Q(e, t = {}) {
913
- let i = this.#U;
918
+ let i = this.#I;
914
919
  if (!i) throw new Error("no memoMethod provided to constructor");
915
- let { context: s, status: n, forceRefresh: o, ...r } = t;
920
+ let { context: s, status: n, forceRefresh: o, ...l } = t;
916
921
  n && o && (n.forceRefresh = true);
917
- let h = this.#C(e, r), l = o || h === void 0;
918
- if (n && (n.memo = l ? "miss" : "hit", l || (n.value = h)), !l) return h;
919
- let c = i(e, h, { options: r, context: s });
920
- return n && (n.value = c), this.#O(e, c, r), c;
922
+ let h = this.#C(e, l), r = o || h === void 0;
923
+ if (n && (n.memo = r ? "miss" : "hit", r || (n.value = h)), !r) return h;
924
+ let c = i(e, h, { options: l, context: s });
925
+ return n && (n.value = c), this.#W(e, c, l), c;
921
926
  }
922
927
  get(e, t = {}) {
923
928
  let { status: i = S.hasSubscribers ? {} : void 0 } = t;
924
- t.status = i, i && (i.op = "get", i.key = e);
929
+ t.status = i, i && (i.op = "get", i.key = e, i.cache = this);
925
930
  let s = this.#C(e, t);
926
931
  return i && (s !== void 0 && (i.value = s), S.hasSubscribers && S.publish(i)), s;
927
932
  }
928
933
  #C(e, t = {}) {
929
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = t, r = this.#s.get(e);
930
- if (r === void 0) {
934
+ let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = t, l = this.#s.get(e);
935
+ if (l === void 0) {
931
936
  o && (o.get = "miss");
932
937
  return;
933
938
  }
934
- let h = this.#t[r], l = this.#e(h);
935
- return o && this.#E(o, r), this.#p(r) ? l ? (o && (o.get = "stale-fetching"), i && h.__staleWhileFetching !== void 0 ? (o && (o.returnedStale = true), h.__staleWhileFetching) : void 0) : (n || this.#v(e, "expire"), o && (o.get = "stale"), i ? (o && (o.returnedStale = true), h) : void 0) : (o && (o.get = l ? "fetching" : "hit"), this.#L(r), s && this.#D(r), l ? h.__staleWhileFetching : h);
939
+ let h = this.#t[l], r = this.#e(h);
940
+ return o && this.#v(o, l), this.#p(l) ? r ? (o && (o.get = "stale-fetching"), i && h.__staleWhileFetching !== void 0 ? (o && (o.returnedStale = true), h.__staleWhileFetching) : void 0) : (n || this.#E(e, "expire"), o && (o.get = "stale"), i ? (o && (o.returnedStale = true), h) : void 0) : (o && (o.get = r ? "fetching" : "hit"), this.#L(l), s && this.#R(l), r ? h.__staleWhileFetching : h);
936
941
  }
937
942
  #$(e, t) {
938
- this.#c[t] = e, this.#a[e] = t;
943
+ this.#u[t] = e, this.#l[e] = t;
939
944
  }
940
945
  #L(e) {
941
- e !== this.#h && (e === this.#l ? this.#l = this.#a[e] : this.#$(this.#c[e], this.#a[e]), this.#$(this.#h, e), this.#h = e);
946
+ e !== this.#h && (e === this.#a ? this.#a = this.#l[e] : this.#$(this.#u[e], this.#l[e]), this.#$(this.#h, e), this.#h = e);
942
947
  }
943
948
  delete(e) {
944
- return this.#v(e, "delete");
949
+ return this.#E(e, "delete");
945
950
  }
946
- #v(e, t) {
947
- S.hasSubscribers && S.publish({ op: "delete", delete: t, key: e });
951
+ #E(e, t) {
952
+ S.hasSubscribers && S.publish({ op: "delete", delete: t, key: e, cache: this });
948
953
  let i = false;
949
954
  if (this.#n !== 0) {
950
955
  let s = this.#s.get(e);
951
- if (s !== void 0) if (this.#g?.[s] && (clearTimeout(this.#g?.[s]), this.#g[s] = void 0), i = true, this.#n === 1) this.#q(t);
956
+ if (s !== void 0) if (this.#g?.[s] && (clearTimeout(this.#g[s]), this.#g[s] = void 0), i = true, this.#n === 1) this.#q(t);
952
957
  else {
953
- this.#R(s);
958
+ this.#x(s);
954
959
  let n = this.#t[s];
955
- if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#w?.(n, e, t), this.#f && this.#r?.push([n, e, t])), this.#s.delete(e), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#c[s];
956
- else if (s === this.#l) this.#l = this.#a[s];
960
+ if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#S?.(n, e, t), this.#f && this.#r?.push([n, e, t])), this.#s.delete(e), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#u[s];
961
+ else if (s === this.#a) this.#a = this.#l[s];
957
962
  else {
958
- let o = this.#c[s];
959
- this.#a[o] = this.#a[s];
960
- let r = this.#a[s];
961
- this.#c[r] = this.#c[s];
963
+ let o = this.#u[s];
964
+ this.#l[o] = this.#l[s];
965
+ let l = this.#l[s];
966
+ this.#u[l] = this.#u[s];
962
967
  }
963
968
  this.#n--, this.#y.push(s);
964
969
  }
965
970
  }
966
971
  if (this.#f && this.#r?.length) {
967
972
  let s = this.#r, n;
968
- for (; n = s?.shift(); ) this.#S?.(...n);
973
+ for (; n = s?.shift(); ) this.#w?.(...n);
969
974
  }
970
975
  return i;
971
976
  }
@@ -978,7 +983,7 @@ var M = class u2 {
978
983
  if (this.#e(i)) i.__abortController.abort(new Error("deleted"));
979
984
  else {
980
985
  let s = this.#i[t];
981
- this.#T && this.#w?.(i, s, e), this.#f && this.#r?.push([i, s, e]);
986
+ this.#T && this.#S?.(i, s, e), this.#f && this.#r?.push([i, s, e]);
982
987
  }
983
988
  }
984
989
  if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#F) {
@@ -986,9 +991,9 @@ var M = class u2 {
986
991
  for (let t of this.#g ?? []) t !== void 0 && clearTimeout(t);
987
992
  this.#g?.fill(void 0);
988
993
  }
989
- if (this.#_ && this.#_.fill(0), this.#l = 0, this.#h = 0, this.#y.length = 0, this.#b = 0, this.#n = 0, this.#f && this.#r) {
994
+ if (this.#_ && this.#_.fill(0), this.#a = 0, this.#h = 0, this.#y.length = 0, this.#b = 0, this.#n = 0, this.#f && this.#r) {
990
995
  let t = this.#r, i;
991
- for (; i = t?.shift(); ) this.#S?.(...i);
996
+ for (; i = t?.shift(); ) this.#w?.(...i);
992
997
  }
993
998
  }
994
999
  };
@@ -1022,6 +1027,10 @@ function range(a, b) {
1022
1027
  function schedule(fn, count) {
1023
1028
  return Array.from({ length: count }, (_, i) => fn(i));
1024
1029
  }
1030
+ function jitter(delayMs) {
1031
+ const half = delayMs / 2;
1032
+ return Math.round(half + Math.random() * half);
1033
+ }
1025
1034
  var DEFAULT_RETRY_AFTER_CAP_MS = 2e4;
1026
1035
  function getErrorResponseHeaders(error) {
1027
1036
  if (error === null || typeof error !== "object") return void 0;
@@ -1099,11 +1108,11 @@ function op(fnOrOptions, options) {
1099
1108
  }
1100
1109
  function _op(fn, options) {
1101
1110
  const shouldCache = options.ttl !== void 0;
1102
- const lruCache = shouldCache ? new M({
1111
+ const lruCache = shouldCache ? new I({
1103
1112
  max: options.maxItems ?? 1e3,
1104
1113
  ttl: options.ttl
1105
1114
  }) : null;
1106
- const keyMap = shouldCache ? new M({
1115
+ const keyMap = shouldCache ? new I({
1107
1116
  max: options.maxItems ?? 1e3,
1108
1117
  ttl: options.ttl
1109
1118
  }) : null;
@@ -1196,6 +1205,7 @@ function _op(fn, options) {
1196
1205
  delay = Math.max(delay, Math.min(cap, hint));
1197
1206
  }
1198
1207
  }
1208
+ delay = jitter(delay);
1199
1209
  if (namePrefix) {
1200
1210
  log.info(
1201
1211
  `${namePrefix}attempt ${attempt + 1}/${retries.length + 1} failed, retrying in ${delay}ms`