javascript - Ramda Js: Setting property on an object using a value from the same object -


using ramda js, need create function can set 1 object property using value of different property on same object. attempt far follows:

var foo = r.set(r.lensprop('bar'), 'foo' + r.prop('foo')); var result = foo({foo:"bar"}); 

desired result:

{foo:"bar", bar:"foobar"} 

actual result:

{foo:"bar", bar: "foofunction f1(a) {... etc"} 

clearly i'm misunderstanding here, , insights how approach appreciated.

lenses not fit when value of 1 property depends on value of property. lambda best here:

const foo = o => r.assoc('bar', 'foo' + o.foo, o);  foo({foo: 'bar'}); // => {foo: 'bar', bar: 'foobar'} 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -