Download react-hook-form/src/logic/generateWatchOutput.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 682 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/src/logic/generateWatchOutput.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/src/logic/generateWatchOutput.ts
-
curl -L -o generateWatchOutput.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/src/logic/generateWatchOutput.ts
682 Bytes
| import type { DeepPartial, FieldValues, Names } from '../types'; | |
| import get from '../utils/get'; | |
| import isString from '../utils/isString'; | |
| export default <T>( | |
| names: string | string[] | undefined, | |
| _names: Names, | |
| formValues?: FieldValues, | |
| isGlobal?: boolean, | |
| defaultValue?: DeepPartial<T> | unknown, | |
| ) => { | |
| if (isString(names)) { | |
| isGlobal && _names.watch.add(names); | |
| return get(formValues, names, defaultValue); | |
| } | |
| if (Array.isArray(names)) { | |
| return names.map( | |
| (fieldName) => ( | |
| isGlobal && _names.watch.add(fieldName), | |
| get(formValues, fieldName) | |
| ), | |
| ); | |
| } | |
| isGlobal && (_names.watchAll = true); | |
| return formValues; | |
| }; | |