proposal-function-memo
proposal-function-memo copied to clipboard
A TC39 proposal for function memoization in the JavaScript language.
Should `memo` be a prototype method, a static function, a function decorator, or multiple? This depends most on whether `memo` will be mostly used on anonymous functions, named function declarations,...
Should the user be required to specify a cache, i.e., what cache-replacement policy they wish to use for memoization? If the cache parameter is optional, then its default presumably would...
Early bikeshedding. No matter what we decide in #2, we will need to decide whether we would rather call the new metafunction “memo” or “memoize”. I’m fine with either.
Maybe this would be another proposal, where different functions could be identified uniquely based on their source location, arguments and closures despite a new Function instance is created. If so,...
How should cache memory management work? Is there a way to get garbage collection by default? (Using WeakMaps for the caches would be ideal…except that WeakMaps do not support primitives...
The most important thing for this proposal to figure out is how it determines that a subsequent call is "equivalent" to a previous call so that it can return the...
There was a great discussion of a `Function.memoize` feature in [es-discourse.group](https://es.discourse.group/t/built-in-function-memoization-with-weak-references/446) a while back. I wrote a [polyfill for it here](https://github.com/NickGard/proposal-function-memoize). Notably, the discussion in the es-discourse group revealed that...
If we go with a Map-like cache (see [policy Maps](https://github.com/js-choi/proposal-policy-map-set)), how should we structure the cache? For example, we could use a tree of Maps, or we could use argument-[tuples](https://github.com/tc39/proposal-record-tuple/blob/main/details.md)...
With return types of generator functions returning an iterable (An object with Symbol.iterator or Symbol.asyncIterator) that can only be iterated through once, I am wondering how these functions would be...
Below is the checklist, we can use this issue to discuss any questions that arise during each of these stage. ## Stage 4 - [ ] committee approval - [...