Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

either

v0.26.1arrow_drop_down
v0.26.1
STATUS
Passing
DOWNLOADS
96
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
7 months ago
SIZE
3 KB
subject
A function wrapping calls to the two functions in an `||` operation,
1 contributor
Use either in your project ?
Copied
npm i @bit/ramda.ramda.either
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
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';
revert changes
reload
toggle layout
maximize
f(8);
modifieddraft
chevron_left
chevron_right
either (
f:Function,
g:Function
) : Function

A function wrapping calls to the two functions in an || operation, returning the result of the first function if it is truth-y and the result of the second function otherwise. Note that this is short-circuited, meaning that the second function will not be invoked if the first returns a truth-y value.

In addition to functions, R.either also accepts any fantasy-land compatible applicative functor.

Example
const gt10 = x => x > 10;
     const even = x => x % 2 === 0;
     const f = R.either(gt10, even);
     f(101); //=> true
     f(8); //=> true

     R.either(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(55)
     R.either([false, false, 'a'], [11]) // => [11, 11, "a"]
Arguments
f: Function

a predicate

g: Function

another predicate

Returns
Function

a function that applies its arguments to `f` and `g` and `||`s their outputs together.