js:
var data = [ {fname: 'Roy', lname: 'Red'}, {fname: 'Gary', lname: 'Green'}, {fname: 'Bob', lname: 'Blue'}, {fname: 'Roy', lname: 'Rudy', alt: 'Alt'}, ]; var dataUpd = R.pipe( R.filter(R.propEq('fname', 'Roy')), //R.filter(R.prop('alt')), )(data); alert( JSON.stringify(dataUpd) );
Result:
Filter all numbers which are more than 5:
const arr = [1,2,3,4,5,6,7,8]; const moreThan5 = n => n > 5; const resMoreThan5 = R.filter(moreThan5)(arr); console.log(resMoreThan5);
notEmpty helper:
js:
var data = [ undefined, null, '', {fname: 'Roy', lname: 'Red'}, {fname: 'Gary', lname: 'Green'}, {fname: 'Bob', lname: 'Blue'}, ]; var notEmpty = R.complement(R.either(R.isEmpty, R.isNil)); var dataUpd = R.pipe( R.filter(notEmpty), )(data); alert( JSON.stringify(dataUpd) );
Result: