@blumintinc/typescript-memoize 1.2.0 → 1.3.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 +218 -218
- package/dist/es2015/memoize-decorator.js.map +1 -1
- package/dist/memoize-decorator.d.ts +10 -10
- package/dist/memoize-decorator.js +249 -248
- package/dist/memoize-decorator.js.map +1 -1
- package/package.json +65 -65
- package/src/memoize-decorator.ts +251 -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,219 @@
|
|
|
1
|
-
|
|
2
|
-
export function Memoize(args) {
|
|
3
|
-
var _a;
|
|
4
|
-
let hashFunction;
|
|
5
|
-
let duration;
|
|
6
|
-
let tags;
|
|
7
|
-
let useDeepEqual =
|
|
8
|
-
if (typeof args === 'object') {
|
|
9
|
-
hashFunction = args.hashFunction;
|
|
10
|
-
duration = args.expiring;
|
|
11
|
-
tags = args.tags;
|
|
12
|
-
useDeepEqual = (_a = args.useDeepEqual) !== null && _a !== void 0 ? _a :
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
hashFunction = args;
|
|
16
|
-
}
|
|
17
|
-
return (target, propertyKey, descriptor) => {
|
|
18
|
-
if (descriptor.value != null) {
|
|
19
|
-
descriptor.value = getNewFunction(descriptor.value, hashFunction, duration, tags, useDeepEqual);
|
|
20
|
-
}
|
|
21
|
-
else if (descriptor.get != null) {
|
|
22
|
-
descriptor.get = getNewFunction(descriptor.get, hashFunction, duration, tags, useDeepEqual);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
throw 'Only put a Memoize() decorator on a method or get accessor.';
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export function MemoizeExpiring(expiring, hashFunction) {
|
|
30
|
-
return Memoize({
|
|
31
|
-
expiring,
|
|
32
|
-
hashFunction
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
const clearCacheTagsMap = new Map();
|
|
36
|
-
export function clear(tags) {
|
|
37
|
-
const cleared = new Set();
|
|
38
|
-
for (const tag of tags) {
|
|
39
|
-
const maps = clearCacheTagsMap.get(tag);
|
|
40
|
-
if (maps) {
|
|
41
|
-
for (const mp of maps) {
|
|
42
|
-
if (!cleared.has(mp)) {
|
|
43
|
-
mp.clear();
|
|
44
|
-
cleared.add(mp);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return cleared.size;
|
|
50
|
-
}
|
|
51
|
-
class DeepEqualMap {
|
|
52
|
-
constructor() {
|
|
53
|
-
this.map = new Map();
|
|
54
|
-
}
|
|
55
|
-
has(key) {
|
|
56
|
-
const entries = Array.from(this.map.values());
|
|
57
|
-
for (const entry of entries) {
|
|
58
|
-
if (equal(entry.key, key)) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
get(key) {
|
|
65
|
-
const entries = Array.from(this.map.values());
|
|
66
|
-
for (const entry of entries) {
|
|
67
|
-
if (equal(entry.key, key)) {
|
|
68
|
-
return entry.value;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
set(key, value) {
|
|
74
|
-
const entries = Array.from(this.map.entries());
|
|
75
|
-
for (const [serializedKey, entry] of entries) {
|
|
76
|
-
if (equal(entry.key, key)) {
|
|
77
|
-
this.map.delete(serializedKey);
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const serializedKey = `${Date.now()}_${Math.random()}`;
|
|
82
|
-
this.map.set(serializedKey, { key, value });
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
clear() {
|
|
86
|
-
this.map.clear();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function getNewFunction(originalMethod, hashFunction, duration = 0, tags, useDeepEqual =
|
|
90
|
-
const propMapName = Symbol(`__memoized_map__`);
|
|
91
|
-
const propDeepMapName = Symbol(`__memoized_deep_map__`);
|
|
92
|
-
return function (...args) {
|
|
93
|
-
let returnedValue;
|
|
94
|
-
if (useDeepEqual) {
|
|
95
|
-
if (!this.hasOwnProperty(propDeepMapName)) {
|
|
96
|
-
Object.defineProperty(this, propDeepMapName, {
|
|
97
|
-
configurable: false,
|
|
98
|
-
enumerable: false,
|
|
99
|
-
writable: false,
|
|
100
|
-
value: new DeepEqualMap()
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
let myMap = this[propDeepMapName];
|
|
104
|
-
if (Array.isArray(tags)) {
|
|
105
|
-
for (const tag of tags) {
|
|
106
|
-
const mapWrapper = {
|
|
107
|
-
clear: () => myMap.clear()
|
|
108
|
-
};
|
|
109
|
-
if (clearCacheTagsMap.has(tag)) {
|
|
110
|
-
clearCacheTagsMap.get(tag).push(mapWrapper);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
clearCacheTagsMap.set(tag, [mapWrapper]);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
let hashKey;
|
|
118
|
-
if (hashFunction === true) {
|
|
119
|
-
hashKey = args;
|
|
120
|
-
}
|
|
121
|
-
else if (hashFunction) {
|
|
122
|
-
hashKey = hashFunction.apply(this, args);
|
|
123
|
-
}
|
|
124
|
-
else if (args.length > 0) {
|
|
125
|
-
hashKey = args.length === 1 ? args[0] : args;
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
hashKey = this;
|
|
129
|
-
}
|
|
130
|
-
const timestampKey = { __timestamp: true, key: hashKey };
|
|
131
|
-
let isExpired = false;
|
|
132
|
-
if (duration > 0) {
|
|
133
|
-
if (!myMap.has(timestampKey)) {
|
|
134
|
-
isExpired = true;
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
let timestamp = myMap.get(timestampKey);
|
|
138
|
-
isExpired = (Date.now() - timestamp) > duration;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (myMap.has(hashKey) && !isExpired) {
|
|
142
|
-
returnedValue = myMap.get(hashKey);
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
returnedValue = originalMethod.apply(this, args);
|
|
146
|
-
myMap.set(hashKey, returnedValue);
|
|
147
|
-
if (duration > 0) {
|
|
148
|
-
myMap.set(timestampKey, Date.now());
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
if (!this.hasOwnProperty(propMapName)) {
|
|
154
|
-
Object.defineProperty(this, propMapName, {
|
|
155
|
-
configurable: false,
|
|
156
|
-
enumerable: false,
|
|
157
|
-
writable: false,
|
|
158
|
-
value: new Map()
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
let myMap = this[propMapName];
|
|
162
|
-
if (Array.isArray(tags)) {
|
|
163
|
-
for (const tag of tags) {
|
|
164
|
-
if (clearCacheTagsMap.has(tag)) {
|
|
165
|
-
clearCacheTagsMap.get(tag).push(myMap);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
clearCacheTagsMap.set(tag, [myMap]);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (hashFunction || args.length > 0 || duration > 0) {
|
|
173
|
-
let hashKey;
|
|
174
|
-
if (hashFunction === true) {
|
|
175
|
-
hashKey = args.map(a => a.toString()).join('!');
|
|
176
|
-
}
|
|
177
|
-
else if (hashFunction) {
|
|
178
|
-
hashKey = hashFunction.apply(this, args);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
hashKey = args[0];
|
|
182
|
-
}
|
|
183
|
-
const timestampKey = `${hashKey}__timestamp`;
|
|
184
|
-
let isExpired = false;
|
|
185
|
-
if (duration > 0) {
|
|
186
|
-
if (!myMap.has(timestampKey)) {
|
|
187
|
-
isExpired = true;
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
let timestamp = myMap.get(timestampKey);
|
|
191
|
-
isExpired = (Date.now() - timestamp) > duration;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
if (myMap.has(hashKey) && !isExpired) {
|
|
195
|
-
returnedValue = myMap.get(hashKey);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
returnedValue = originalMethod.apply(this, args);
|
|
199
|
-
myMap.set(hashKey, returnedValue);
|
|
200
|
-
if (duration > 0) {
|
|
201
|
-
myMap.set(timestampKey, Date.now());
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
const hashKey = this;
|
|
207
|
-
if (myMap.has(hashKey)) {
|
|
208
|
-
returnedValue = myMap.get(hashKey);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
returnedValue = originalMethod.apply(this, args);
|
|
212
|
-
myMap.set(hashKey, returnedValue);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return returnedValue;
|
|
217
|
-
};
|
|
218
|
-
}
|
|
1
|
+
import equal from '@blumintinc/fast-deep-equal';
|
|
2
|
+
export function Memoize(args) {
|
|
3
|
+
var _a;
|
|
4
|
+
let hashFunction;
|
|
5
|
+
let duration;
|
|
6
|
+
let tags;
|
|
7
|
+
let useDeepEqual = true;
|
|
8
|
+
if (typeof args === 'object') {
|
|
9
|
+
hashFunction = args.hashFunction;
|
|
10
|
+
duration = args.expiring;
|
|
11
|
+
tags = args.tags;
|
|
12
|
+
useDeepEqual = (_a = args.useDeepEqual) !== null && _a !== void 0 ? _a : true;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
hashFunction = args;
|
|
16
|
+
}
|
|
17
|
+
return (target, propertyKey, descriptor) => {
|
|
18
|
+
if (descriptor.value != null) {
|
|
19
|
+
descriptor.value = getNewFunction(descriptor.value, hashFunction, duration, tags, useDeepEqual);
|
|
20
|
+
}
|
|
21
|
+
else if (descriptor.get != null) {
|
|
22
|
+
descriptor.get = getNewFunction(descriptor.get, hashFunction, duration, tags, useDeepEqual);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw 'Only put a Memoize() decorator on a method or get accessor.';
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function MemoizeExpiring(expiring, hashFunction) {
|
|
30
|
+
return Memoize({
|
|
31
|
+
expiring,
|
|
32
|
+
hashFunction
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const clearCacheTagsMap = new Map();
|
|
36
|
+
export function clear(tags) {
|
|
37
|
+
const cleared = new Set();
|
|
38
|
+
for (const tag of tags) {
|
|
39
|
+
const maps = clearCacheTagsMap.get(tag);
|
|
40
|
+
if (maps) {
|
|
41
|
+
for (const mp of maps) {
|
|
42
|
+
if (!cleared.has(mp)) {
|
|
43
|
+
mp.clear();
|
|
44
|
+
cleared.add(mp);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return cleared.size;
|
|
50
|
+
}
|
|
51
|
+
class DeepEqualMap {
|
|
52
|
+
constructor() {
|
|
53
|
+
this.map = new Map();
|
|
54
|
+
}
|
|
55
|
+
has(key) {
|
|
56
|
+
const entries = Array.from(this.map.values());
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
if (equal(entry.key, key)) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
get(key) {
|
|
65
|
+
const entries = Array.from(this.map.values());
|
|
66
|
+
for (const entry of entries) {
|
|
67
|
+
if (equal(entry.key, key)) {
|
|
68
|
+
return entry.value;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
set(key, value) {
|
|
74
|
+
const entries = Array.from(this.map.entries());
|
|
75
|
+
for (const [serializedKey, entry] of entries) {
|
|
76
|
+
if (equal(entry.key, key)) {
|
|
77
|
+
this.map.delete(serializedKey);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const serializedKey = `${Date.now()}_${Math.random()}`;
|
|
82
|
+
this.map.set(serializedKey, { key, value });
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
clear() {
|
|
86
|
+
this.map.clear();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function getNewFunction(originalMethod, hashFunction, duration = 0, tags, useDeepEqual = true) {
|
|
90
|
+
const propMapName = Symbol(`__memoized_map__`);
|
|
91
|
+
const propDeepMapName = Symbol(`__memoized_deep_map__`);
|
|
92
|
+
return function (...args) {
|
|
93
|
+
let returnedValue;
|
|
94
|
+
if (useDeepEqual) {
|
|
95
|
+
if (!this.hasOwnProperty(propDeepMapName)) {
|
|
96
|
+
Object.defineProperty(this, propDeepMapName, {
|
|
97
|
+
configurable: false,
|
|
98
|
+
enumerable: false,
|
|
99
|
+
writable: false,
|
|
100
|
+
value: new DeepEqualMap()
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
let myMap = this[propDeepMapName];
|
|
104
|
+
if (Array.isArray(tags)) {
|
|
105
|
+
for (const tag of tags) {
|
|
106
|
+
const mapWrapper = {
|
|
107
|
+
clear: () => myMap.clear()
|
|
108
|
+
};
|
|
109
|
+
if (clearCacheTagsMap.has(tag)) {
|
|
110
|
+
clearCacheTagsMap.get(tag).push(mapWrapper);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
clearCacheTagsMap.set(tag, [mapWrapper]);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
let hashKey;
|
|
118
|
+
if (hashFunction === true) {
|
|
119
|
+
hashKey = args;
|
|
120
|
+
}
|
|
121
|
+
else if (hashFunction) {
|
|
122
|
+
hashKey = hashFunction.apply(this, args);
|
|
123
|
+
}
|
|
124
|
+
else if (args.length > 0) {
|
|
125
|
+
hashKey = args.length === 1 ? args[0] : args;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
hashKey = this;
|
|
129
|
+
}
|
|
130
|
+
const timestampKey = { __timestamp: true, key: hashKey };
|
|
131
|
+
let isExpired = false;
|
|
132
|
+
if (duration > 0) {
|
|
133
|
+
if (!myMap.has(timestampKey)) {
|
|
134
|
+
isExpired = true;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
let timestamp = myMap.get(timestampKey);
|
|
138
|
+
isExpired = (Date.now() - timestamp) > duration;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (myMap.has(hashKey) && !isExpired) {
|
|
142
|
+
returnedValue = myMap.get(hashKey);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
returnedValue = originalMethod.apply(this, args);
|
|
146
|
+
myMap.set(hashKey, returnedValue);
|
|
147
|
+
if (duration > 0) {
|
|
148
|
+
myMap.set(timestampKey, Date.now());
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
if (!this.hasOwnProperty(propMapName)) {
|
|
154
|
+
Object.defineProperty(this, propMapName, {
|
|
155
|
+
configurable: false,
|
|
156
|
+
enumerable: false,
|
|
157
|
+
writable: false,
|
|
158
|
+
value: new Map()
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
let myMap = this[propMapName];
|
|
162
|
+
if (Array.isArray(tags)) {
|
|
163
|
+
for (const tag of tags) {
|
|
164
|
+
if (clearCacheTagsMap.has(tag)) {
|
|
165
|
+
clearCacheTagsMap.get(tag).push(myMap);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
clearCacheTagsMap.set(tag, [myMap]);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (hashFunction || args.length > 0 || duration > 0) {
|
|
173
|
+
let hashKey;
|
|
174
|
+
if (hashFunction === true) {
|
|
175
|
+
hashKey = args.map(a => a.toString()).join('!');
|
|
176
|
+
}
|
|
177
|
+
else if (hashFunction) {
|
|
178
|
+
hashKey = hashFunction.apply(this, args);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
hashKey = args[0];
|
|
182
|
+
}
|
|
183
|
+
const timestampKey = `${hashKey}__timestamp`;
|
|
184
|
+
let isExpired = false;
|
|
185
|
+
if (duration > 0) {
|
|
186
|
+
if (!myMap.has(timestampKey)) {
|
|
187
|
+
isExpired = true;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
let timestamp = myMap.get(timestampKey);
|
|
191
|
+
isExpired = (Date.now() - timestamp) > duration;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (myMap.has(hashKey) && !isExpired) {
|
|
195
|
+
returnedValue = myMap.get(hashKey);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
returnedValue = originalMethod.apply(this, args);
|
|
199
|
+
myMap.set(hashKey, returnedValue);
|
|
200
|
+
if (duration > 0) {
|
|
201
|
+
myMap.set(timestampKey, Date.now());
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
const hashKey = this;
|
|
207
|
+
if (myMap.has(hashKey)) {
|
|
208
|
+
returnedValue = myMap.get(hashKey);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
returnedValue = originalMethod.apply(this, args);
|
|
212
|
+
myMap.set(hashKey, returnedValue);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return returnedValue;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
219
|
//# sourceMappingURL=memoize-decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoize-decorator.js","sourceRoot":"","sources":["../../src/memoize-decorator.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"memoize-decorator.js","sourceRoot":"","sources":["../../src/memoize-decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,6BAA6B,CAAC;AAUhD,MAAM,UAAU,OAAO,CAAC,IAAgD;;IACvE,IAAI,YAAyC,CAAC;IAC9C,IAAI,QAAiC,CAAC;IACtC,IAAI,IAAyB,CAAC;IAC9B,IAAI,YAAY,GAAgC,IAAI,CAAC;IAErD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC7B,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACjC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QACzB,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACjB,YAAY,SAAG,IAAI,CAAC,YAA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AG,CAAC,YAAY,CAAC,EAAE;wBAE7B,SAAS,GAAG,IAAI,CAAC;qBACjB;yBAAM;wBACN,IAAI,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;wBACxC,SAAS,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,QAAQ,CAAC;qBAChD;iBACD;gBAED,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE;oBACrC,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;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 {};
|