* Creates a function that memoizes the result of `func`. If `resolver` is * provided it will be used to determine 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 used
(func, resolver)
| 40691 | * // => { 'name': 'penelope', 'age': 1 } |
| 40692 | */ |
| 40693 | function memoize(func, resolver) { |
| 40694 | if (!isFunction(func)) { |
| 40695 | throw new TypeError; |
| 40696 | } |
| 40697 | var memoized = function() { |
| 40698 | var cache = memoized.cache, |
| 40699 | key = resolver ? resolver.apply(this, arguments) : keyPrefix + arguments[0]; |
| 40700 | |
| 40701 | return hasOwnProperty.call(cache, key) |
| 40702 | ? cache[key] |
| 40703 | : (cache[key] = func.apply(this, arguments)); |
| 40704 | } |
| 40705 | memoized.cache = {}; |
| 40706 | return memoized; |
| 40707 | } |
| 40708 | |
| 40709 | /** |
| 40710 | * Creates a function that is restricted to execute `func` once. Repeat calls to |
nothing calls this directly
no test coverage detected