refactor(core): dedupe shared config and runtime helpers

This commit is contained in:
Peter Steinberger
2026-02-16 14:52:03 +00:00
parent 544ffbcf7b
commit 04892ee230
68 changed files with 1966 additions and 2018 deletions

15
src/infra/map-size.ts Normal file
View File

@@ -0,0 +1,15 @@
export function pruneMapToMaxSize<K, V>(map: Map<K, V>, maxSize: number): void {
const limit = Math.max(0, Math.floor(maxSize));
if (limit <= 0) {
map.clear();
return;
}
while (map.size > limit) {
const oldest = map.keys().next();
if (oldest.done) {
break;
}
map.delete(oldest.value);
}
}