MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / trim

Function trim

src/common/cache.js:96–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 1

delFunction · 0.85

Tested by

no test coverage detected