Download react-hook-form/src/utils/move.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 322 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/src/utils/move.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/src/utils/move.ts
-
curl -L -o move.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/src/utils/move.ts
322 Bytes
| import isUndefined from './isUndefined'; | |
| export default <T>( | |
| data: (T | undefined)[], | |
| from: number, | |
| to: number, | |
| ): (T | undefined)[] => { | |
| if (!Array.isArray(data)) { | |
| return []; | |
| } | |
| if (isUndefined(data[to])) { | |
| data[to] = undefined; | |
| } | |
| data.splice(to, 0, data.splice(from, 1)[0]); | |
| return data; | |
| }; | |