medikoo / memoizee

Complete memoize/cache solution for JavaScript
ISC License
1.73k stars 61 forks source link

Exposing `memoizee/weak` as a build option #71

Open rokoroku opened 7 years ago

rokoroku commented 7 years ago

Why not have we memoizee/weak as a build option like { weak: true }? Rather than importing two modules, it seems good to use it as a build option.

medikoo commented 7 years ago

Good question.

Main reason is that, handling of weak mode is very different from default, and if it's multiargument case, then it comes down to memoization factory (where memoized function is created per every different first argument (object), similarly as with memoizee/method where we have memoized function per each different this).

Anyway I plan in March, to do larger refactor (which will end with v1), so it's possible that there will be just one entry point for weak mode or not. Soon I should open the roadmap issue for that.

Rather than importing two modules, it seems good to use it as a build option

You don't need to import two modules, just importing memoizee/weak is good enough to configure WeakMap based memoization.

I'll leave this open, to take into account having one front for whatever memoization mode.