Download chakra-ui/packages/react/src/utils/memo.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 367 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/chakra-ui/packages/react/src/utils/memo.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/chakra-ui/packages/react/src/utils/memo.ts
-
curl -L -o memo.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/chakra-ui/packages/react/src/utils/memo.ts
367 Bytes
| import stringify from "fast-safe-stringify" | |
| export const memo = <T extends (...args: any[]) => any>(fn: T): T => { | |
| const cache: Record<string, any> = Object.create(null) | |
| function get(...args: any[]) { | |
| const key = args.map((v) => stringify(v)).join("|") | |
| if (cache[key] === undefined) cache[key] = fn(...args) | |
| return cache[key] | |
| } | |
| return get as T | |
| } | |