const R = require('ramda');
const o = {action: 'refresh', row: {row: {
action: '<a role="refresh">Refresh</a>',
instrument: { value: 'Poke', _validated: 'true'},
amount: { value: 1000, _validated: 'true'},
sale: { value: true, _validated: 'true'}
}
}};
const i = ['k1.k2.a.actionkey:action', 'k1.k2.r.rowkey:row.row'];
const log = (...x) => {
return R.tap(console.log.bind(console, '--->', ...x));
};
const sanitizedPairs = R.pipe(
R.split(':'),
R.converge(R.pair, [R.head, R.last]),
R.map(R.trim)
);
const dotPath = R.useWith(R.path, [R.split('.')]);
const propsDotPath = R.useWith(R.ap, [R.map(dotPath), R.of]);
const newPath = R.compose(R.map(R.split('.')), R.pluck(0), R.map(sanitizedPairs));
const oldDotPath = R.compose(R.pluck(1), R.map(sanitizedPairs));
const newPairs = R.converge(R.zip, [newPath, R.uncurryN(2, R.compose(propsDotPath, oldDotPath))]);
//newObj
const fromDeepPairs = R.reduce((acc, xs) => R.assocPath(R.head(xs), R.last(xs), acc), {});
fromDeepPairs(newPairs(i)(o));