UNPKG

1.05 kBTypeScriptView Raw
1import { BiTypedMethodDecorator1 } from './factory';
2import { MemoizeConfig } from './shared';
3/**
4 * Creates a function that memoizes the result of func. If resolver is provided,
5 * it determines the cache key for storing the result based on the arguments provided to the memoized function.
6 * By default, the first argument provided to the memoized function is used as the map cache key.
7 * The func is invoked with the this binding of the memoized function.
8 *
9 * You can use a Function or a string that references a method on the class as the resolver.
10 * You can also use a configuration object that lets provide a prexisting cache or specify
11 * the map type to use.
12 *
13 * @example
14 *
15 * class MyClass {
16 * @Memoize({ type: WeakMap })
17 * getName(item) {
18 * return item.name;
19 * }
20 *
21 * @Memoize('getName')
22 * getLastName(item) {
23 * return item.lastName;
24 * }
25 * }
26 */
27export declare const Memoize: BiTypedMethodDecorator1<string | Function | MemoizeConfig<any, any>>;
28export { Memoize as memoize };
29export default Memoize;