| 44 | } |
| 45 | |
| 46 | function createCacheNode<T>(): CacheNode<T> { |
| 47 | return { |
| 48 | s: UNTERMINATED, // status, represents whether the cached computation returned a value or threw an error |
| 49 | v: undefined, // value, either the cached result or an error, depending on s |
| 50 | o: null, // object cache, a WeakMap where non-primitive arguments are stored |
| 51 | p: null, // primitive cache, a regular Map where primitive arguments are stored. |
| 52 | }; |
| 53 | } |
| 54 | |
| 55 | export function cache<A: Iterable<mixed>, T>(fn: (...A) => T): (...A) => T { |
| 56 | return function () { |