export function cache any>(fn: T): T { const store = new Map>(); return ((...args) => { const key = args.length === 1 ? args[0] : JSON.stringify(args); const cached = store.get(key); if (store.has(key)) { return cached as ReturnType; } const result = Reflect.apply(fn, undefined, args); store.set(key, result); return result; }) as T; }