These are chat archives for ramda/ramda

Oct 2018
Andreas Herd
Oct 24 2018 06:54
is there a better way to do this: ? I want to filter an object array where a property value is contained in a value-array
it seems a bit clumsy the way i did it
Riku Tiira
Oct 24 2018 07:01

I guess you could also do

shapes.filter(R.propSatisfies(R.pipe(R.equals, R.any(R.__, ['circle', 'square'])), 'type’))

A bit code-golfy though

I’d personally just opt for shapes.filter(({ type }) => [‘circle’, ’square’].includes(type))
Andreas Herd
Oct 24 2018 07:03
hmm ye that looks the nicest, gotta check if I have Array.includes polyfill
filter(where({ type: contains(R.__, ['circle', 'square'])}))(shapes)
this is also quite ok
Riku Tiira
Oct 24 2018 07:07
oh lol
my version was way too complex with any vs contains
you can also do shapes.filter(R.propSatisfies(R.contains(R.__, ['circle', 'square']), 'type’))
Andreas Herd
Oct 24 2018 07:34
yep thanks, now i realized i need the other side of the filter too, so had to switch to partition :)
Miguel Dorta
Oct 24 2018 08:24
@ben-eb thanks ben!
Ben Briggs
Oct 24 2018 08:58
@ellipticaldoor You're welcome :)