1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var memoize = require("lodash/memoize");
|
4 | var factory_1 = require("./factory");
|
5 | var applicators_1 = require("./applicators");
|
6 | /**
|
7 | * Creates a function that memoizes the result of func. If resolver is provided,
|
8 | * it determines the cache key for storing the result based on the arguments provided to the memoized function.
|
9 | * By default, the first argument provided to the memoized function is used as the map cache key.
|
10 | * The func is invoked with the this binding of the memoized function.
|
11 | *
|
12 | * You can use a Function or a string that references a method on the class as the resolver.
|
13 | * You can also use a configuration object that lets provide a prexisting cache or specify
|
14 | * the map type to use.
|
15 | *
|
16 | * @example
|
17 | *
|
18 | * class MyClass {
|
19 | * @Memoize({ type: WeakMap })
|
20 | * getName(item) {
|
21 | * return item.name;
|
22 | * }
|
23 | *
|
24 | * @Memoize('getName')
|
25 | * getLastName(item) {
|
26 | * return item.lastName;
|
27 | * }
|
28 | * }
|
29 | */
|
30 | exports.Memoize = factory_1.DecoratorFactory.createInstanceDecorator(new factory_1.DecoratorConfig(memoize, new applicators_1.MemoizeApplicator(), { optionalParams: true }));
|
31 | exports.memoize = exports.Memoize;
|
32 | exports.default = exports.Memoize;
|
33 | //# sourceMappingURL=memoize.js.map |
\ | No newline at end of file |