Function
getCache
(
cache: Map<CacheKeyFragment, any>,
...key: TKey
)
Source from the content-addressed store, hash-verified
| 3 | export type CacheKeyFragment = string | number | boolean; |
| 4 | |
| 5 | export function getCache<TKey extends CacheKeyFragment[]>( |
| 6 | cache: Map<CacheKeyFragment, any>, |
| 7 | ...key: TKey |
| 8 | ) { |
| 9 | const cacheKeys = key.slice(0, -1); |
| 10 | |
| 11 | return R.reduce( |
| 12 | (c, fragment) => { |
| 13 | return c.get(fragment) || c.set(fragment, new Map()).get(fragment); |
| 14 | }, |
| 15 | cache, |
| 16 | cacheKeys |
| 17 | ) as Map<CacheKeyFragment, any>; |
| 18 | } |
Tested by
no test coverage detected
Used in the wild real call sites across dependent graphs
searching dependent graphs…