Spaces:
Runtime error
Runtime error
File size: 487 Bytes
4327358 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
export function CacheAsync() {
return function (
target: any,
propertyKey: string,
descriptor: PropertyDescriptor,
) {
const original = descriptor.value;
const symbol = Symbol(`__cache_${propertyKey}`);
descriptor.value = async function (...args: any[]) {
const key = symbol;
if (this[key]) {
return this[key];
}
const result = await original.apply(this, args);
this[key] = result;
return result;
};
};
}
|