These are chat archives for ramda/ramda

12th
Jan 2019
Adrian Skierniewski
@AdrianSkierniewski
Jan 12 07:16
@Bradcomp I need to convert dot notation string into nested object
and I was wondering if ramda have something useful that could easily do that because I don't want to write procedural style recursive function :)
Rakesh Pai
@rakeshpai
Jan 12 10:48
@Bradcomp Haven't tried this, but should work:
const pathToLens = pipe( split('.'), lensPath );
const createPath = path => set( pathToLens(path), true, {} );
createPath('a.b.c'); // should be { a: { b: { c: true } } }
Sorry, I meant to address that to @AdrianSkierniewski
Rakesh Pai
@rakeshpai
Jan 12 11:39
@m59peacemaker That might be the best way to do it. I'd consider if prices needs to be set at all, considering that it's just a computed value, but that depends on what you're trying to do. Otherwise, I can't really think of a way to improve it. I feel your not-quite-right feeling, though. :)
Ben Briggs
@ben-eb
Jan 12 17:10
@rakeshpai Can tweak slightly so that we can set something different at the path :)
const pathToLens = pipe( split('.'), lensPath );
const createPath = path => flip(set(pathToLens(path)))({});

createPath('a.b.c')(false);