MCPcopy
hub / github.com/mui/material-ui / memoize

Function memoize

packages/mui-system/src/memoize/memoize.ts:1–13  ·  view source on GitHub ↗
(
  fn: (arg: ArgType) => ReturnType,
)

Source from the content-addressed store, hash-verified

1export 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}

Callers

nothing calls this directly

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…