memoize-weak icon indicating copy to clipboard operation
memoize-weak copied to clipboard

Add primitive vs object arguments distinction to docs

Open aaronbeall opened this issue 1 year ago • 0 comments

First of all, thanks for this library! I wrote something similar and came across this later.

One thing that was not clear from the docs was how you handle primitive args. I had realized in my own implementation (that also uses an argument tree) that if the first argument is a primitive it will never get garbage collected. I was curious how this library handles it since the docs made it sound like somehow it was. (There's no reason in principle that primitives could not be weak referenced, but JS just doesn't seem to expose this ability.) It took looking into the implementation to realize that "Previous arguments are automatically garbage-collected" only applies to objects.

aaronbeall avatar Mar 26 '23 16:03 aaronbeall