function memoizeCompare (fn, isEqual) {
  const memoize = function memoize () {
    const args = []
    for (let i = 0; i < arguments.length; i++) {
      args[i] = arguments[i]
    }

    for (let c = 0; c < memoize.cache.length; c++) {
      const cached = memoize.cache[c]

      if (isEqual(args, cached.args)) {
        // TODO: move this cache entry to the top so recently used entries move up?
        return cached.res
      }
    }

    const res = fn.apply(fn, args)
    memoize.cache.unshift({ args, res })

    return res
  }

  memoize.cache = []

  return memoize
}
Memoize a given function by caching all results and the arguments,
and comparing against the arguments of previous results before
executing again.
This is less performant than `memoize` which calculates a hash,
which is very fast to compare. Use `memoizeCompare` only when it is
not possible to create a unique serializable hash from the function
arguments.
The isEqual function must compare two sets of arguments
and return true when equal (can be a deep equality check for example).
@param {function} fn
@param {function(a: *, b: *) : boolean} isEqual
@returns {function}