I'm a bit confused by the deepEquals behaviour here. As there is an option to enable deepObject equivalence I was not expecting objects to be equivalent (with deepObject=false) in this scenario.
I was expecting that the multiple calculation would be run twice. Once for the first multiply(a,b,c) and again for the multiply(a2,b,c). The same is true for arrays.
I dug into the code a little and it looks like the intention is to penetrate 1 level deep by default?
As far as I know the arguments to a function will always be the array-like Arguments object, and I don't think that would ever be the same across function calls so it would make sense to me to start with something that handles the array specifically and then drops into the shallow or deepEquals possibilities.
I'm a bit confused by the deepEquals behaviour here. As there is an option to enable deepObject equivalence I was not expecting objects to be equivalent (with
deepObject=false
) in this scenario.I was expecting that the multiple calculation would be run twice. Once for the first
multiply(a,b,c)
and again for themultiply(a2,b,c)
. The same is true for arrays.I dug into the code a little and it looks like the intention is to penetrate 1 level deep by default?
As far as I know the arguments to a function will always be the array-like Arguments object, and I don't think that would ever be the same across function calls so it would make sense to me to start with something that handles the array specifically and then drops into the shallow or deepEquals possibilities.
Perhaps
deepEquals
anddeepObject
equals should be separate arguments, but I've reuseddeepObject
in this example PR: https://github.com/erikras/lru-memoize/pull/77It should be easy to see the current behaviour for these unit tests by putting:
back in.