MCPcopy Create free account
hub / github.com/vercel/vercel / cachedLookup

Function cachedLookup

packages/node/src/typescript.ts:105–115  ·  view source on GitHub ↗

* Cached fs operation wrapper.

(fn: (arg: string) => T)

Source from the content-addressed store, hash-verified

103 * Cached fs operation wrapper.
104 */
105function 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
117const require_ = createRequire(__filename);
118

Callers 1

getBuildFunction · 0.85

Calls 3

getMethod · 0.65
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected