Share your code. Components are building blocks, you are the architect.

utils/if-else
v1.1.0
1.1.0
1.0.0
MIT
PUBLIC
3
Build: fail
BuildFail
Build Status: fail
Creates a function that will process either the `onTrue` or the `onFalse`

Please configure Bit as a scoped registry to install components with NPM.Learn more

npm config set '@bit:registry' https://node.bitsrc.io
Use utils/if-else in your project
npm i @bit/bit.ramda.utils.if-else
Copied

ifElse (condition:Function, onTrue:Function, onFalse:Function) : Function

Creates a function that will process either the onTrue or the onFalse function depending upon the result of the condition predicate.

Example

var incCount = R.ifElse(
       R.has('count'),
       R.over(R.lensProp('count'), R.inc),
       R.assoc('count', 1)
     );
     incCount({});           //=> { count: 1 }
     incCount({ count: 1 }); //=> { count: 2 }

Arguments

condition: Function

A predicate function

onTrue: Function

A function to invoke when the `condition` evaluates to a truthy value.

onFalse: Function

A function to invoke when the `condition` evaluates to a falsy value.

Returns

Function

A new function that will process either the `onTrue` or the `onFalse` function depending upon the result of the `condition` predicate.