Skip to content

Instantly share code, notes, and snippets.

@dinocarl
Created January 21, 2022 15:52
Show Gist options
  • Save dinocarl/23e8e2be543b62d9937c3288103f82c7 to your computer and use it in GitHub Desktop.
Save dinocarl/23e8e2be543b62d9937c3288103f82c7 to your computer and use it in GitHub Desktop.
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