UNPKG

ramda-extension

Version:

Helpful functions built on top of the mighty Ramda

20 lines (19 loc) 782 B
import { o, values, mapObjIndexed, map, objOf, useWith, flip, call, identity, compose } from 'ramda'; import applyCompose from './applyCompose'; import splitByDot from './splitByDot'; import mergeDeepRightAll from './mergeDeepRightAll'; /** * Unfolds input object by dot delimetered path inside its keys. * * @func * @category Object * * @example * * R_.unfoldObjectDots({'a.b.c': 1, 'd.e.f': 2, 'g': 3}) * // {a: {b: {c: 1}}, d: {e: {f: 2}}, g: 3} * * @sig Object -> Object */ var unfoldObjectDots = /*#__PURE__*/o( /*#__PURE__*/o(mergeDeepRightAll, values), /*#__PURE__*/mapObjIndexed( /*#__PURE__*/useWith( /*#__PURE__*/flip(call), [identity, /*#__PURE__*/compose(applyCompose, /*#__PURE__*/map(objOf), splitByDot)]))); export default unfoldObjectDots;