ortense
7/27/2017 - 6:24 PM

simple and small memoize function

simple and small memoize function

const memoize = fn => {
  const memo = {}
  
  return (...args) => {
    if (args in memo) return memo[args]
    return (memo[args] = fn.apply(null, args))
  }
}