1 var MapCache = require(
'./_MapCache');
4 var FUNC_ERROR_TEXT =
'Expected a function';
50 function memoize(func, resolver) {
51 if (typeof func !=
'function' || (resolver != null && typeof resolver !=
'function')) {
52 throw new TypeError(FUNC_ERROR_TEXT);
54 var memoized =
function() {
56 key = resolver ? resolver.apply(
this, args) : args[0],
57 cache = memoized.cache;
60 return cache.get(key);
62 var result = func.apply(
this, args);
63 memoized.cache = cache.set(key, result) || cache;
66 memoized.cache =
new (memoize.Cache || MapCache);
71 memoize.Cache = MapCache;
73 module.exports = memoize;