Ramda allPass

js:


var data = [

 {fname: 'Roy', lname: 'Red', admin: true, active: true},

 {fname: 'Gary', lname: 'Green', admin: false, active: true},

 {fname: 'Bob', lname: 'Blue', admin: true, active: false},

 {fname: 'Jack', lname: 'Black', admin: false, active: false},

 {fname: 'Mike', lname: 'White', admin: true, active: true},

];



var isActive = R.propEq('active', true);

var isAdmin = R.propEq('admin', true);

var isActiveAdmin = R.allPass([isActive, isAdmin]);



var dataUpd = R.pipe(

  R.filter(isActiveAdmin),

  //R.filter(isActive),

  //R.filter(isAdmin),

)(data);



alert( JSON.stringify(dataUpd) );

Result:

Leave a Comment