performance and usability improvements

This commit is contained in:
Joeri Exelmans 2025-10-23 19:16:46 +02:00
parent a25396b6f2
commit ab988898c0
18 changed files with 381 additions and 206 deletions

View file

@ -11,3 +11,15 @@ export function compactTime(timeMs: number) {
return `${timeMs} ms`;
}
export function memoize<InType,OutType>(fn: (i: InType) => OutType) {
const cache = new Map();
return (i: InType) => {
const found = cache.get(i);
if (found) {
return found;
}
const result = fn(i);
cache.set(i, result);
return result;
}
}