Closed saggiyogesh closed 6 years ago
This actually works as intended. memoizee
by default only takes into account mandatory arguments (resolved on basis of function's length).
To force memoizee
to take into account optional arguments (ones with default values) you need to pass length
option (in above case length: 1
, as for your function length === 0
)
Yeah thanks, it's working now after giving length
option.
Please update the same in the documentation.
Please update the same in the documentation.
Documentation was actually quite clear on that: https://github.com/medikoo/memoizee#arguments-length. Still I added a note about how default parameters behave (language feature) -> https://github.com/medikoo/memoizee/commit/a988fe35ee4533858e88b64829e4dc06f79efe53
In the above snippet,
fn
is the memoized version offn1
which is having a default parameter. When an object is passed in the arguments,fn1
still returning results of default arguments, ignoring the passed argument (o).