chore: Make memoization slightly faster and more reliable
This is not related to any of the ongoing work. Feel free to consider that the lowest priority.
@stbrody's hypothesis about memoization changing shape of a StreamID instance caught my attention. That should not affect Jest snapshots, but technically memoization modifies the instance.
Apparently, there is a better way to handle memoization. It is 20%-40% faster, smaller(802B vs 1.4kB now). It does not pollute the instances thanks to WeakMap usage.
Also, it could support LRU for memoization, so we could use it more widely.
the change to js-ceramic isn't really signficant, the real thing that needs review is the implementation of the mapmoize package: https://github.com/ukstv/mapmoize/blob/main/src/index.ts. (note @ukstv the NPM repo doesn't link to the source code, I had to find it on your github directly)
I don't really feel equipped to review the mapmoize library implementation. Maybe @zachferland or @oed do?
@stbrody Thanks. Added a link to the repo to package.json
TIL: Apparently shortcut like "repository": "npm/npm" is not displayed on npm package page.
Folks @stbrody @willex @stephhuynh18 any news on approval?
The merge is obviously conditional on conflict resolution.
Folks @stbrody @willex @stephhuynh18 any news on approval?
The merge is obviously conditional on conflict resolution.
Can you open a pr for the implementation of mapMemoize? That's actually the important and complex part.
@stephhuynh18 Thank you! @stbrody Good to go?