Download chakra-ui/packages/react/src/utils/clone.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 350 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/chakra-ui/packages/react/src/utils/clone.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/chakra-ui/packages/react/src/utils/clone.ts
-
curl -L -o clone.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/chakra-ui/packages/react/src/utils/clone.ts
350 Bytes
| export function clone<T extends Record<string, any>>(obj: T): T { | |
| if (obj === null || typeof obj !== "object") return obj | |
| if (Array.isArray(obj)) return obj.map((prop) => clone(prop)) as any | |
| const _clone = Object.create(Object.getPrototypeOf(obj)) | |
| for (const key of Object.keys(obj)) { | |
| _clone[key] = clone(obj[key]) | |
| } | |
| return _clone | |
| } | |