UNPKG

@universis/common

Version:

Universis - common directives and services

43 lines (42 loc) 1.7 kB
/** * Returns a string which represents a key generated by @asyncMemoize() or @memoize() decorators * @param target - The target object * @param propertyKey - A string which represents the method that is going to be called * @param args - An optional param array of arguments * @example * // calculate memoized key for myObject.getFunc1(100, true) * const key = getMemoizeKey(myObject, 'getFunc1', 100, true); */ export declare function getMemoizeKey(target: any, propertyKey: string, ...args: any[]): string; /** * Removes a key-value pair generated by @asyncMemoize() or @memoize() decorators * @param target - The target object * @param propertyKey - A string which represents the method that is going to be called * @param args - An optional param array of arguments * @example * // removes memoized key for myObject.getFunc1(100, true) * removeMemoizeKey(myObject, 'getFunc1', 100, true); */ export declare function removeMemoizeKey(target: any, propertyKey: string, ...args: any[]): void; /** * Use @asyncMemoize() decorator to memoize the result of an async method to storage * @example * class TestClass1 { * @asyncMemoize() * async getItems() { * return ['apple', 'lemon', 'orange']; * } * } */ export declare function asyncMemoize(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void; /** * Use @memoize() decorator to memoize the result of an async method to storage * @example * class TestClass1 { * @memoize() * getItems() { * return ['apple', 'lemon', 'orange']; * } * } */ export declare function memoize(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;