Ramda includes

js:

const cities = ['London', 'Boston', 'Prague'];

const filterByCities = item => R.includes(R.prop('city', item), cities);

const data = [
  { name: 'John', city: 'London' },
  { name: 'Lenny', city: 'New York' },
  { name: 'Andrew', city: 'Boston' },
  { name: 'Peter', city: 'Prague' },
  { name: 'Anna', city: 'Bratislava' },
  { name: 'Albert', city: 'Bratislava' },
  { name: 'Adam', city: 'Trnava' },
  { name: 'Robert', city: 'Bratislava' },
  { name: 'Robert', city: 'Prague' }
];

var dataUpd = R.pipe(
  R.filter(filterByCities)
)(data);

alert( JSON.stringify(dataUpd) );

Result:

Leave a Comment