if-else

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
1 KB
Creates a function that will process either the `onTrue` or the `onFalse` function depending upon the result of the `condition` predicate.
1 contributor
Install if-else as a package?
Copied
npm i @bit/justin-capalbo.ramda.if-else
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
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
const 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.

Help and resources