Memoizes precisely two-argument functions
npm install memoize-two-argsyarn add memoize-two-args or npm i memoize-two-argsAims to solve a common problem which is typically slow or memory-inefficient: memoizing exactly two arguments which are both objects. Typically this is done using an LRU implementation backed by an array structure with O(n) lookups. This function, however, uses WeakMap (or Map if you need to be able to memoize strings, undefined, etc) giving it O(1 * 2) lookup efficiency.
js
import memoize from 'memoize-two-args'const memoizedFn = memoize(
function (arg1, arg2) {
// do work
}
)
const objA = {...}
const objB = {...}
return memoizedFn(objA, objB)
`$3
`js
...
const memoizedFn = memoize(someFunc, Map)
...
``