* Cached fs operation wrapper.
(fn: (arg: string) => T)
| 103 | * Cached fs operation wrapper. |
| 104 | */ |
| 105 | function cachedLookup<T>(fn: (arg: string) => T): (arg: string) => T { |
| 106 | const cache = new Map<string, T>(); |
| 107 | |
| 108 | return (arg: string): T => { |
| 109 | if (!cache.has(arg)) { |
| 110 | cache.set(arg, fn(arg)); |
| 111 | } |
| 112 | |
| 113 | return cache.get(arg) as T; |
| 114 | }; |
| 115 | } |
| 116 | |
| 117 | const require_ = createRequire(__filename); |
| 118 |