UNPKG

mout

Version:

Modular Utilities

18 lines (17 loc) 731 B
/** * Creates a function that memoizes the result of `fn`. If `resolver` is * provided it determines the cache key for storing the result based on the * arguments provided to the memoized function. By default, the first argument * provided to the memoized function is coerced to a string and used as the * cache key. The `fn` is invoked with the `this` binding of the memoized * function. Modified from lodash. * * @param {Function} fn Function to have its output memoized. * @param {Function} context Function to resolve the cache key. * @return {Function} Returns the new memoized function. */ declare function memoize(fn: any, resolver: any): { (): any; cache: {}; }; export default memoize;