Ramda anyPass

js:

var data = [
 {fname: 'Roy', lname: 'Red', admin: true, editor: true},
 {fname: 'Gary', lname: 'Green', admin: false, editor: true},
 {fname: 'Bob', lname: 'Blue', admin: true, editor: false},
 {fname: 'Jack', lname: 'Black', admin: false, editor: false},
 {fname: 'Mike', lname: 'White', admin: true, editor: true},
];
 
var isAdmin = R.propEq('admin', true);
var isEditor = R.propEq('editor', true);
var isAdminOrEditor = R.anyPass([isAdmin, isEditor]);
 
var dataUpd = R.pipe(
  R.filter(isAdminOrEditor),
)(data);
 
alert( JSON.stringify(dataUpd) );

Result:

Leave a Reply

Your email address will not be published. Required fields are marked *