Created
January 21, 2022 15:52
-
-
Save dinocarl/23e8e2be543b62d9937c3288103f82c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = {'a.b': 1, 'c.d': 7, 'c.d': 9} | |
const assocPathDataLast = curry( | |
(mergeAble, pathList, val) => assocPath(pathList, val, mergeAble) | |
); | |
const processKeys = compose( | |
split('.'), | |
head | |
); | |
const expandKeys = compose( | |
apply(assocPathDataLast({})), | |
juxt([processKeys, last]) | |
); | |
const toNested = compose( | |
mergeAll, | |
map(expandKeys), | |
toPairs | |
); | |
toNested(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment