export function memo(func: () => T): () => T { let cache: T | undefined; return (): T => { if (cache === undefined) { cache = func(); } return cache; }; } export function asyncMemo(func: () => Promise): () => Promise { let cache: T | undefined; return async (): Promise => { if (cache === undefined) { cache = await func(); } return cache; }; }