diff --git a/src/mol-util/memoize.ts b/src/mol-util/memoize.ts index d74f25380edcf97df9cce41639e6aeb5f16944b4..c91d1f3e748b06b689782da9439093d92d774061 100644 --- a/src/mol-util/memoize.ts +++ b/src/mol-util/memoize.ts @@ -4,6 +4,7 @@ * @author David Sehnal <david.sehnal@gmail.com> */ + /** Cache the latest result from calls to a function with any number of arguments */ export function memoizeLatest<Args extends any[], T>(f: (...args: Args) => T): (...args: Args) => T { let lastArgs: any[] | undefined = void 0, value: any = void 0; return (...args) => { @@ -23,6 +24,7 @@ export function memoizeLatest<Args extends any[], T>(f: (...args: Args) => T): ( } } +/** Cache all results from calls to a function with a single argument */ export function memoize1<A, T>(f: (a: A) => T): (a: A) => T { const cache = new Map<A, T>(); return a => {