1
2
3
4
5
6
7
8
const memoize = pureFunc => {
const cache = {};
return function() {
const argStr = JSON.stringify(arguments);
cache[argStr] = cache[argStr] || pureFunc.apply(pureFunc, arguments);
return cache[argStr];
};
};