[function][memoize] should accept multiple parameters
Author: kaitoukid-1412Created Jul 12, 2026Updated Jul 15, 2026
hotfix
function memoize(fn, options = {}) {
const { cache = new Map(), getCacheKey } = options
const memoizedFn = function(...args) {
const key = getCacheKey ? getCacheKey(...args) : JSON.stringify(args) // ?
if (cache.has(key)) {
return cache.get(key)
}
const result = fn.call(this, ...args)
cache.set(key, result)
return result
}
memoizedFn.cache = cache
return memoizedFn
}
memoize(console.log)(1,2,3)
Source: toss/es-toolkit