@blumintinc/typescript-memoize 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +342 -342
- package/dist/es2015/memoize-decorator.d.ts +10 -10
- package/dist/es2015/memoize-decorator.js +260 -218
- package/dist/es2015/memoize-decorator.js.map +1 -1
- package/dist/memoize-decorator.d.ts +10 -10
- package/dist/memoize-decorator.js +291 -248
- package/dist/memoize-decorator.js.map +1 -1
- package/package.json +65 -65
- package/src/memoize-decorator.ts +308 -250
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
interface MemoizeArgs {
|
|
2
|
-
expiring?: number;
|
|
3
|
-
hashFunction?: boolean | ((...args: any[]) => any);
|
|
4
|
-
tags?: string[];
|
|
5
|
-
useDeepEqual?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function Memoize(args?: MemoizeArgs | MemoizeArgs['hashFunction']): (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
8
|
-
export declare function MemoizeExpiring(expiring: number, hashFunction?: MemoizeArgs['hashFunction']): (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
9
|
-
export declare function clear(tags: string[]): number;
|
|
10
|
-
export {};
|
|
1
|
+
interface MemoizeArgs {
|
|
2
|
+
expiring?: number;
|
|
3
|
+
hashFunction?: boolean | ((...args: any[]) => any);
|
|
4
|
+
tags?: string[];
|
|
5
|
+
useDeepEqual?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function Memoize(args?: MemoizeArgs | MemoizeArgs['hashFunction']): (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
8
|
+
export declare function MemoizeExpiring(expiring: number, hashFunction?: MemoizeArgs['hashFunction']): (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
9
|
+
export declare function clear(tags: string[]): number;
|
|
10
|
+
export {};
|
|
@@ -1,219 +1,261 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
1
|
+
import equal from '@blumintinc/fast-deep-equal';
|
|
2
|
+
function isOpaqueClassInstance(obj) {
|
|
3
|
+
if (obj == null || typeof obj !== 'object' || Array.isArray(obj))
|
|
4
|
+
return false;
|
|
5
|
+
const proto = Object.getPrototypeOf(obj);
|
|
6
|
+
if (proto === null || proto === Object.prototype)
|
|
7
|
+
return false;
|
|
8
|
+
if (proto.constructor === Object)
|
|
9
|
+
return false;
|
|
10
|
+
if (obj instanceof Date || obj instanceof RegExp ||
|
|
11
|
+
obj instanceof Map || obj instanceof Set)
|
|
12
|
+
return false;
|
|
13
|
+
return Object.keys(obj).length === 0;
|
|
14
|
+
}
|
|
15
|
+
function containsOpaqueValue(obj) {
|
|
16
|
+
if (typeof obj !== 'object' || obj === null)
|
|
17
|
+
return false;
|
|
18
|
+
return Object.values(obj).some(isOpaqueClassInstance);
|
|
19
|
+
}
|
|
20
|
+
function memoizeEqual(a, b) {
|
|
21
|
+
if (a === b)
|
|
22
|
+
return true;
|
|
23
|
+
if (a == null || b == null)
|
|
24
|
+
return false;
|
|
25
|
+
if (typeof a !== 'object' || typeof b !== 'object')
|
|
26
|
+
return equal(a, b);
|
|
27
|
+
if (isOpaqueClassInstance(a) || isOpaqueClassInstance(b))
|
|
28
|
+
return false;
|
|
29
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
30
|
+
if (a.length !== b.length)
|
|
31
|
+
return false;
|
|
32
|
+
return a.every((el, i) => memoizeEqual(el, b[i]));
|
|
33
|
+
}
|
|
34
|
+
if (!containsOpaqueValue(a) && !containsOpaqueValue(b)) {
|
|
35
|
+
return equal(a, b);
|
|
36
|
+
}
|
|
37
|
+
const keysA = Object.keys(a);
|
|
38
|
+
const keysB = Object.keys(b);
|
|
39
|
+
if (keysA.length !== keysB.length)
|
|
40
|
+
return false;
|
|
41
|
+
return keysA.every(key => key in b &&
|
|
42
|
+
memoizeEqual(a[key], b[key]));
|
|
43
|
+
}
|
|
44
|
+
export function Memoize(args) {
|
|
45
|
+
var _a;
|
|
46
|
+
let hashFunction;
|
|
47
|
+
let duration;
|
|
48
|
+
let tags;
|
|
49
|
+
let useDeepEqual = true;
|
|
50
|
+
if (typeof args === 'object') {
|
|
51
|
+
hashFunction = args.hashFunction;
|
|
52
|
+
duration = args.expiring;
|
|
53
|
+
tags = args.tags;
|
|
54
|
+
useDeepEqual = (_a = args.useDeepEqual) !== null && _a !== void 0 ? _a : true;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
hashFunction = args;
|
|
58
|
+
}
|
|
59
|
+
return (target, propertyKey, descriptor) => {
|
|
60
|
+
if (descriptor.value != null) {
|
|
61
|
+
descriptor.value = getNewFunction(descriptor.value, hashFunction, duration, tags, useDeepEqual);
|
|
62
|
+
}
|
|
63
|
+
else if (descriptor.get != null) {
|
|
64
|
+
descriptor.get = getNewFunction(descriptor.get, hashFunction, duration, tags, useDeepEqual);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
throw 'Only put a Memoize() decorator on a method or get accessor.';
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export function MemoizeExpiring(expiring, hashFunction) {
|
|
72
|
+
return Memoize({
|
|
73
|
+
expiring,
|
|
74
|
+
hashFunction
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const clearCacheTagsMap = new Map();
|
|
78
|
+
export function clear(tags) {
|
|
79
|
+
const cleared = new Set();
|
|
80
|
+
for (const tag of tags) {
|
|
81
|
+
const maps = clearCacheTagsMap.get(tag);
|
|
82
|
+
if (maps) {
|
|
83
|
+
for (const mp of maps) {
|
|
84
|
+
if (!cleared.has(mp)) {
|
|
85
|
+
mp.clear();
|
|
86
|
+
cleared.add(mp);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return cleared.size;
|
|
92
|
+
}
|
|
93
|
+
class DeepEqualMap {
|
|
94
|
+
constructor() {
|
|
95
|
+
this.map = new Map();
|
|
96
|
+
}
|
|
97
|
+
has(key) {
|
|
98
|
+
const entries = Array.from(this.map.values());
|
|
99
|
+
for (const entry of entries) {
|
|
100
|
+
if (memoizeEqual(entry.key, key)) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
get(key) {
|
|
107
|
+
const entries = Array.from(this.map.values());
|
|
108
|
+
for (const entry of entries) {
|
|
109
|
+
if (memoizeEqual(entry.key, key)) {
|
|
110
|
+
return entry.value;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
set(key, value) {
|
|
116
|
+
const entries = Array.from(this.map.entries());
|
|
117
|
+
for (const [serializedKey, entry] of entries) {
|
|
118
|
+
if (memoizeEqual(entry.key, key)) {
|
|
119
|
+
this.map.delete(serializedKey);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const serializedKey = `${Date.now()}_${Math.random()}`;
|
|
124
|
+
this.map.set(serializedKey, { key, value });
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
clear() {
|
|
128
|
+
this.map.clear();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function getNewFunction(originalMethod, hashFunction, duration = 0, tags, useDeepEqual = true) {
|
|
132
|
+
const propMapName = Symbol(`__memoized_map__`);
|
|
133
|
+
const propDeepMapName = Symbol(`__memoized_deep_map__`);
|
|
134
|
+
return function (...args) {
|
|
135
|
+
let returnedValue;
|
|
136
|
+
if (useDeepEqual) {
|
|
137
|
+
if (!this.hasOwnProperty(propDeepMapName)) {
|
|
138
|
+
Object.defineProperty(this, propDeepMapName, {
|
|
139
|
+
configurable: false,
|
|
140
|
+
enumerable: false,
|
|
141
|
+
writable: false,
|
|
142
|
+
value: new DeepEqualMap()
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
let myMap = this[propDeepMapName];
|
|
146
|
+
if (Array.isArray(tags)) {
|
|
147
|
+
for (const tag of tags) {
|
|
148
|
+
const mapWrapper = {
|
|
149
|
+
clear: () => myMap.clear()
|
|
150
|
+
};
|
|
151
|
+
if (clearCacheTagsMap.has(tag)) {
|
|
152
|
+
clearCacheTagsMap.get(tag).push(mapWrapper);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
clearCacheTagsMap.set(tag, [mapWrapper]);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
let hashKey;
|
|
160
|
+
if (hashFunction === true) {
|
|
161
|
+
hashKey = args;
|
|
162
|
+
}
|
|
163
|
+
else if (hashFunction) {
|
|
164
|
+
hashKey = hashFunction.apply(this, args);
|
|
165
|
+
}
|
|
166
|
+
else if (args.length > 0) {
|
|
167
|
+
hashKey = args.length === 1 ? args[0] : args;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
hashKey = this;
|
|
171
|
+
}
|
|
172
|
+
const timestampKey = { __timestamp: true, key: hashKey };
|
|
173
|
+
let isExpired = false;
|
|
174
|
+
if (duration > 0) {
|
|
175
|
+
if (!myMap.has(timestampKey)) {
|
|
176
|
+
isExpired = true;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
let timestamp = myMap.get(timestampKey);
|
|
180
|
+
isExpired = (Date.now() - timestamp) > duration;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (myMap.has(hashKey) && !isExpired) {
|
|
184
|
+
returnedValue = myMap.get(hashKey);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
returnedValue = originalMethod.apply(this, args);
|
|
188
|
+
myMap.set(hashKey, returnedValue);
|
|
189
|
+
if (duration > 0) {
|
|
190
|
+
myMap.set(timestampKey, Date.now());
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
if (!this.hasOwnProperty(propMapName)) {
|
|
196
|
+
Object.defineProperty(this, propMapName, {
|
|
197
|
+
configurable: false,
|
|
198
|
+
enumerable: false,
|
|
199
|
+
writable: false,
|
|
200
|
+
value: new Map()
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
let myMap = this[propMapName];
|
|
204
|
+
if (Array.isArray(tags)) {
|
|
205
|
+
for (const tag of tags) {
|
|
206
|
+
if (clearCacheTagsMap.has(tag)) {
|
|
207
|
+
clearCacheTagsMap.get(tag).push(myMap);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
clearCacheTagsMap.set(tag, [myMap]);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (hashFunction || args.length > 0 || duration > 0) {
|
|
215
|
+
let hashKey;
|
|
216
|
+
if (hashFunction === true) {
|
|
217
|
+
hashKey = args.map(a => a.toString()).join('!');
|
|
218
|
+
}
|
|
219
|
+
else if (hashFunction) {
|
|
220
|
+
hashKey = hashFunction.apply(this, args);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
hashKey = args[0];
|
|
224
|
+
}
|
|
225
|
+
const timestampKey = `${hashKey}__timestamp`;
|
|
226
|
+
let isExpired = false;
|
|
227
|
+
if (duration > 0) {
|
|
228
|
+
if (!myMap.has(timestampKey)) {
|
|
229
|
+
isExpired = true;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
let timestamp = myMap.get(timestampKey);
|
|
233
|
+
isExpired = (Date.now() - timestamp) > duration;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (myMap.has(hashKey) && !isExpired) {
|
|
237
|
+
returnedValue = myMap.get(hashKey);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
returnedValue = originalMethod.apply(this, args);
|
|
241
|
+
myMap.set(hashKey, returnedValue);
|
|
242
|
+
if (duration > 0) {
|
|
243
|
+
myMap.set(timestampKey, Date.now());
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
const hashKey = this;
|
|
249
|
+
if (myMap.has(hashKey)) {
|
|
250
|
+
returnedValue = myMap.get(hashKey);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
returnedValue = originalMethod.apply(this, args);
|
|
254
|
+
myMap.set(hashKey, returnedValue);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return returnedValue;
|
|
259
|
+
};
|
|
260
|
+
}
|
|
219
261
|
//# sourceMappingURL=memoize-decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoize-decorator.js","sourceRoot":"","sources":["../../src/memoize-decorator.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"memoize-decorator.js","sourceRoot":"","sources":["../../src/memoize-decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,6BAA6B,CAAC;AAMhD,SAAS,qBAAqB,CAAC,GAAY;IAC1C,IAAI,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/E,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAEzC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAE/D,IAAI,KAAK,CAAC,WAAW,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IAE/C,IAAI,GAAG,YAAY,IAAI,IAAI,GAAG,YAAY,MAAM;QAC/C,GAAG,YAAY,GAAG,IAAI,GAA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AO,EAAE,aAAa,CAAC,CAAC;oBAClC,IAAI,QAAQ,GAAG,CAAC,EAAE;wBACjB,KAAK,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;qBACpC;iBACD;aAED;iBAAM;gBACN,MAAM,OAAO,GAAG,IAAI,CAAC;gBACrB,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;oBACvB,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;iBACnC;qBAAM;oBACN,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBACjD,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;iBAClC;aACD;SACD;QAED,OAAO,aAAa,CAAC;IACtB,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
interface MemoizeArgs {
|
|
2
|
-
expiring?: number;
|
|
3
|
-
hashFunction?: boolean | ((...args: any[]) => any);
|
|
4
|
-
tags?: string[];
|
|
5
|
-
useDeepEqual?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function Memoize(args?: MemoizeArgs | MemoizeArgs['hashFunction']): (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
8
|
-
export declare function MemoizeExpiring(expiring: number, hashFunction?: MemoizeArgs['hashFunction']): (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
9
|
-
export declare function clear(tags: string[]): number;
|
|
10
|
-
export {};
|
|
1
|
+
interface MemoizeArgs {
|
|
2
|
+
expiring?: number;
|
|
3
|
+
hashFunction?: boolean | ((...args: any[]) => any);
|
|
4
|
+
tags?: string[];
|
|
5
|
+
useDeepEqual?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function Memoize(args?: MemoizeArgs | MemoizeArgs['hashFunction']): (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
8
|
+
export declare function MemoizeExpiring(expiring: number, hashFunction?: MemoizeArgs['hashFunction']): (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
9
|
+
export declare function clear(tags: string[]): number;
|
|
10
|
+
export {};
|