These are chat archives for ramda/ramda

29th
Apr 2016
David Langford
@That-David-Guy
Apr 29 2016 01:00
Is this the most concise way to do this?
@ram-bot
const data = 
 [ {a:'1', b:'2', d:'1'}
 , {a:'4', b:'5', c:'6'} ]
const obj = {a: '4', b:'UPDATED'}

const mergeIfMatchOnKey = 
  (key, baseObj) => 
  R.ifElse(
    R.propEq(key, R.prop(key, baseObj)),
    R.merge(R.__, baseObj),
    R.identity
  )

const updateMatched = mergeIfMatchOnKey('a', obj)
R.map(updateMatched, data)
ram-bot
@ram-bot
Apr 29 2016 01:00
[ { a: '1', b: '2', d: '1' }, { a: '4', b: 'UPDATED', c: '6' } ]
David Langford
@That-David-Guy
Apr 29 2016 01:00
I find myself regularly using map to update one value. It is getting a bit tedious.
Brad Compton (he/him)
@Bradcomp
Apr 29 2016 03:10
@That-David-Guy Here's a slight improvement: http://goo.gl/Nk6l5u
I'm not having much luck on making it pointfree
Brad Compton (he/him)
@Bradcomp
Apr 29 2016 03:19
Maybe this would be more useful though? http://goo.gl/v0iTdN
David Langford
@That-David-Guy
Apr 29 2016 04:12
@Bradcomp I like the last one. I didn't know about R.when, seems to be what I was looking for
Brad Compton (he/him)
@Bradcomp
Apr 29 2016 04:38
@That-David-Guy there's also R.unless, which is just the opposite
David Langford
@That-David-Guy
Apr 29 2016 04:42
:)
Craig Dallimore
@craigdallimore
Apr 29 2016 09:06
Hello!
It looks like pipeP will resolve even if one of the piped Promises rejects, is that right?
Or rather, I'm looking to sequence n promises, rejecting early if one doesn't succeed.
Craig Dallimore
@craigdallimore
Apr 29 2016 09:35
No, I think I am wrong and pipeP does what I initially expected.
Scott Sauyet
@CrossEye
Apr 29 2016 10:51
@iamstarkov: sorry, was ill last night. Will try to look today.
@dypsilon: points-free is a technique that at times can make code much clearer. But the other times -- when it obscures your intent -- don't use it. We shouldn't make a fetish of it.
Vladimir Starkov
@iamstarkov
Apr 29 2016 12:24
@CrossEye no worries, thanks for your interest
Lewis
@6ewis
Apr 29 2016 14:09
@Stefano Vozza: @Bradcomp what about now http://goo.gl/8aWGUU (and by the way the function suggestion should only receive one arg)
Lewis
@6ewis
Apr 29 2016 14:15
what is your preferred version out of the three? @all
Vladimir Starkov
@iamstarkov
Apr 29 2016 15:05
@6ewis can you add expectation to the example?
Lewis
@6ewis
Apr 29 2016 15:25
@iamstarkov basically whatever value you pass to the functipn suggestions is filtered and a new object is returned with only the ones that have the pass value - it filters only based on two fields: client_number and client_name