| 94 | timer = setTimeout(trim, lifetime + OVERRUN); |
| 95 | } |
| 96 | function trim() { |
| 97 | const now = performance.now(); |
| 98 | let closestExpiry = Number.MAX_SAFE_INTEGER; |
| 99 | // eslint-disable-next-line guard-for-in |
| 100 | for (const key in cache) { |
| 101 | const { expiry } = cache[key]; |
| 102 | if (expiry < now) { |
| 103 | del(key); |
| 104 | } else if (expiry < closestExpiry) { |
| 105 | closestExpiry = expiry; |
| 106 | } |
| 107 | } |
| 108 | minLifetime = closestExpiry - now; |
| 109 | timer = closestExpiry < Number.MAX_SAFE_INTEGER |
| 110 | ? setTimeout(trim, minLifetime + OVERRUN) |
| 111 | : 0; |
| 112 | } |
| 113 | } |