( fn: (arg: ArgType) => ReturnType, )
| 1 | export default function memoize<ArgType extends keyof any = any, ReturnType = any>( |
| 2 | fn: (arg: ArgType) => ReturnType, |
| 3 | ): (arg: ArgType) => ReturnType { |
| 4 | const cache: Record<string, ReturnType> = {}; |
| 5 | |
| 6 | return (arg: ArgType) => { |
| 7 | if (cache[arg as any] === undefined) { |
| 8 | cache[arg as any] = fn(arg); |
| 9 | } |
| 10 | |
| 11 | return cache[arg as any]; |
| 12 | }; |
| 13 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…