MCPcopy Create free account
hub / github.com/SethGammon/Citadel / pruneByLastSeen

Function pruneByLastSeen

scripts/watch.js:93–102  ·  view source on GitHub ↗

Drop oldest-lastSeen entries until the map holds at most `max`.

(map, max)

Source from the content-addressed store, hash-verified

91
92/** Drop oldest-lastSeen entries until the map holds at most `max`. */
93function pruneByLastSeen(map, max) {
94 const keys = Object.keys(map);
95 if (keys.length <= max) return;
96 keys.sort((a, b) =>
97 String(map[a].lastSeen || '').localeCompare(String(map[b].lastSeen || ''))
98 );
99 for (const key of keys.slice(0, keys.length - max)) {
100 delete map[key];
101 }
102}
103
104// -- State management ---------------------------------------------------------
105

Callers 1

runScanFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected