UNPKG

427 BTypeScriptView Raw
1/**
2 * Cache the result of a function on an object
3 *
4 * We could have used @decorators to make this nicer but we don't use them anywhere yet,
5 * so let's keep it simple and readable.
6 */
7export declare function cached<A extends object, B>(obj: A, sym: symbol, fn: () => B): B;
8/**
9 * Like 'cached', but async
10 */
11export declare function cachedAsync<A extends object, B>(obj: A, sym: symbol, fn: () => Promise<B>): Promise<B>;