function memoize (func, hashFunc) {
hashFunc = hashFunc || function () {
return arguments[0];
}
const memoizedFunc = function () {
let result;
let key = hashFunc.apply(null, arguments);
if (memoizedFunc.cache[key] !== undefined) {
result = memoizedFunc.cache[key];
} else {
result = func.apply(null, arguments);
memoizedFunc.cache[key] = result;
}
return result;
}
memoizedFunc.cache = {};
return memoizedFunc;
}