Returns the new memoized function.
const object = { 'a': 1, 'b': 2 }
const other = { 'c': 3, 'd': 4 }
const values = memoize(values)
values(object)
// => [1, 2]
values(other)
// => [3, 4]
object.a = 2
values(object)
// => [1, 2]
// Modify the result cache.
values.cache.set(object, ['a', 'b'])
values(object)
// => ['a', 'b']
// Replace `memoize.Cache` constructor implementation.
memoize.Cache = WeakMap
Creates a function that memoizes the result of
func
. Ifresolver
is provided, it determines the cache key for storing the result based on the arguments provided to the memoized function. By default, the first argument provided to the memoized function is used as the map cache key. Thefunc
is invoked with thethis
binding of the memoized function.Note: The cache is exposed as the
cache
property on the memoized function. Its creation may be customized by replacing thememoize.Cache
constructor with one whose instances implement theMap
method interface ofclear
,delete
,get
,has
, andset
.