Download material-table/src/utils/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 857 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/material-table/src/utils/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/material-table/src/utils/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/material-table/src/utils/index.js
857 Bytes
| export const byString = (o, s) => { | |
| if (!s) { | |
| return; | |
| } | |
| s = s.replace(/\[(\w+)\]/g, ".$1"); // convert indexes to properties | |
| s = s.replace(/^\./, ""); // strip a leading dot | |
| var a = s.split("."); | |
| for (var i = 0, n = a.length; i < n; ++i) { | |
| var x = a[i]; | |
| if (o && x in o) { | |
| o = o[x]; | |
| } else { | |
| return; | |
| } | |
| } | |
| return o; | |
| }; | |
| export const setByString = (obj, path, value) => { | |
| var schema = obj; // a moving reference to internal objects within obj | |
| path = path.replace(/\[(\w+)\]/g, ".$1"); // convert indexes to properties | |
| path = path.replace(/^\./, ""); // strip a leading dot | |
| var pList = path.split("."); | |
| var len = pList.length; | |
| for (var i = 0; i < len - 1; i++) { | |
| var elem = pList[i]; | |
| if (!schema[elem]) schema[elem] = {}; | |
| schema = schema[elem]; | |
| } | |
| schema[pList[len - 1]] = value; | |
| }; | |