Reputation: 3518
How can I can I get opposite value with ramda? I am trying to archive the following:
R.opposite(true) //false
R.opposite(false) // true
Upvotes: 1
Views: 801
Reputation: 18961
As Felix mentioned, you can use not to negate a value:
A function that returns the ! of its argument. It will return true when passed false-y value, and false when passed a truth-y one.
not(true) //=> false
An in case you need to negate the outcome of a function, you can use complement:
Takes a function f and returns a function g such that if called with the same arguments when f returns a "truthy" value, g returns false and when f returns a "falsy" value g returns true.
complement(equals(true))(true) //=> false
Upvotes: 3