4

Ramda remove : Ramda Repl link

The following is the given example, it removes specific numbers from an Array:

R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8]

Now I created an Array of objects, one being empty:

var objArray = [{id: 1, name: 'Leon'},{id: 2, name: 'Paulo'},{}];

When I try:

R.remove({}, objArray);

or

R.remove(R.isEmpty, objArray);

It returns a function:

enter image description here

Why would that be you suppose?

1 Answer 1

10

Figured it out:

const filteredAlerts = R.filter(Util.notEmpty, res.alerts);

I needed to filter by objects that are NOT empty.

This is my Util.notEmpty function:

const notEmpty = R.compose(R.not, R.isEmpty);

Sign up to request clarification or add additional context in comments.

3 Comments

A nicer way to define notEmpty is R.complement(R.isEmpty). Better yet one could use R.reject rather than R.filter. The expression would then become R.reject(R.isEmpty, res.alerts) with no need for a helper function. :)
@LeonGaban, regarding ramda stuff, davidchambers is gonna be your go-to guy
@naomik thanks! Starting following him now, love Ramda :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.