I am new to Ramda and i am trying to find out element that us matching the given property key and property value. Below one works for me.
R.find(R.propEq('propertyName', 'propertyVal'));
However, what i am looking for is the propertyName from a given list. I mean i need a function that looks up for the elements from possbile list.. something like below
R.find(R.propEq('propertyName', ['propertyVal1', 'propertyVal2']
Please suggest what function should be used here to find elements by possible property values
1
I’d recommend to flip R.includes
const list = [
{ name: 'Apple' },
{ name: 'Banana' },
{ name: 'Avocado' }
];
const fruit = R.filter(
R.propSatisfies(R.includes(R.__, ['Banana', 'Apple']), 'name'),
);
console.log(
fruit(list),
)
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.30.1/ramda.js" integrity="sha512-FHBrUNR2Aspc5CQI8/3KQAmtud6erZKGG+BBdT5EqL2i1OcKP9POVu2ZLVDAMxmoc7go1kIWnq6WzmRjdsOxTw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>