(fn: (arg: T) => R)
| 80 | * Cached fs operation wrapper. |
| 81 | */ |
| 82 | export function cachedLookup<T, R>(fn: (arg: T) => R): (arg: T) => R { |
| 83 | const cache = new Map<T, R>(); |
| 84 | |
| 85 | return (arg: T): R => { |
| 86 | if (!cache.has(arg)) { |
| 87 | const v = fn(arg); |
| 88 | cache.set(arg, v); |
| 89 | return v; |
| 90 | } |
| 91 | return cache.get(arg)!; |
| 92 | }; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * @internal |
no test coverage detected
searching dependent graphs…