Download react-hook-form/scripts/README/Insert.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 470 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/scripts/README/Insert.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/scripts/README/Insert.js
-
curl -L -o Insert.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/scripts/README/Insert.js
470 Bytes
| import generators from './Generators.js'; | |
| /* | |
| * Match lines starting with `~` | |
| */ | |
| const insert_id = /^~\S*$/gm; | |
| const comment_unknown = (type) => `<!-- Unknown Insertion Type : '${type}' -->`; | |
| function insert(raw) { | |
| const type = toType(raw); | |
| return generators[type]?.() ?? comment_unknown(type); | |
| } | |
| function toType(string) { | |
| return string.trim().substring(1); | |
| } | |
| export default function insertInto(template) { | |
| return template.replace(insert_id, insert); | |
| } | |