Memoize function with multiply arguments of any type, but it
clears cache every time it reaches the limit. Use it when you need
deep equality for cache lookup and afraid of memory leak.
example
constaddFlag = obj=> ({...obj, flag:true }); constmemoize = memoizeDeepSizeLimit(2, addFlag)); memoize({test:2}); // from addFlag call memoize({test:2}); // from cache memoize({test:3}); //from addFlag call memoize({test:4}); // from addFlag call memoize({test:2}); // from addFlag call (memory was cleared)
Type parameters
T: Function
Parameters
maxSize: number
fn: T
Returns T
fn
Memoize function with multiply arguments of any type, but it
clears cache every time it reaches the limit. Use it when you need
deep equality for cache lookup and afraid of memory leak.
example
constaddFlag = obj=> ({...obj, flag:true }); constmemoize = memoizeDeepSizeLimit(2, addFlag)); memoize({test:2}); // from addFlag call memoize({test:2}); // from cache memoize({test:3}); //from addFlag call memoize({test:4}); // from addFlag call memoize({test:2}); // from addFlag call (memory was cleared)
Memoize function with multiply arguments of any type, but it clears cache every time it reaches the limit. Use it when you need deep equality for cache lookup and afraid of memory leak.