var memoize = function(func, hasher) {
var memoize = function(key) {
var cache = memoize.cache;
var address = '' + (hasher ? hasher.apply(this, arguments) : key);
if (!cache[address]) {
cache[address] = func.apply(this, arguments);
}
return cache[address];
};
memoize.cache = {};
return memoize;
}
function add(a, b) {
console.log("add")
return a + b
}
let addMemory = memoize(add, function(...res) {
return JSON.stringify(res)
})
console.log(addMemory(10, 20))
console.log(addMemory(10, 20))