MCPcopy
hub / github.com/vercel/next.js / memoize

Function memoize

packages/eslint-plugin-next/src/rules/no-html-link-for-pages.ts:24–33  ·  view source on GitHub ↗
(fn: (...args: any[]) => T)

Source from the content-addressed store, hash-verified

22const fsExistsSyncCache = {}
23
24const memoize = <T = any>(fn: (...args: any[]) => T) => {
25 const cache = {}
26 return (...args: any[]): T => {
27 const key = JSON.stringify(args)
28 if (cache[key] === undefined) {
29 cache[key] = fn(...args)
30 }
31 return cache[key]
32 }
33}
34
35const cachedGetUrlFromPagesDirectories = memoize(getUrlFromPagesDirectories)
36const cachedGetUrlFromAppDirectory = memoize(getUrlFromAppDirectory)

Callers 1

Calls 2

fnFunction · 0.50
stringifyMethod · 0.45

Tested by

no test coverage detected