unless

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
922 B
Tests the final argument by passing it to the given predicate function.
1 contributor
Install unless as a package?
Copied
npm i @bit/justin-capalbo.ramda.unless
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
unless (
pred:Function,
whenFalseFn:Function,
x:*
) : *

Tests the final argument by passing it to the given predicate function. If the predicate is not satisfied, the function will return the result of calling the whenFalseFn function with the same argument. If the predicate is satisfied, the argument is returned as is.

Example
let safeInc = R.unless(R.isNil, R.inc);
     safeInc(null); //=> null
     safeInc(1); //=> 2
Arguments
pred: Function

A predicate function

whenFalseFn: Function

A function to invoke when the pred evaluates to a falsy value.

x: *

An object to test with the pred function and pass to whenFalseFn if necessary.

Returns
*

Either `x` or the result of applying `x` to `whenFalseFn`.

Help and resources