Ramda filter

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:

hasData 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:

Leave a Reply

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