main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | var _curry3 =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_curry3.js");
|
---|
4 | /**
|
---|
5 | * Tests the final argument by passing it to the given predicate function. If
|
---|
6 | * the predicate is not satisfied, the function will return the result of
|
---|
7 | * calling the `whenFalseFn` function with the same argument. If the predicate
|
---|
8 | * is satisfied, the argument is returned as is.
|
---|
9 | *
|
---|
10 | * @func
|
---|
11 | * @memberOf R
|
---|
12 | * @since v0.18.0
|
---|
13 | * @category Logic
|
---|
14 | * @sig (a -> Boolean) -> (a -> b) -> a -> a | b
|
---|
15 | * @param {Function} pred A predicate function
|
---|
16 | * @param {Function} whenFalseFn A function to invoke when the `pred` evaluates
|
---|
17 | * to a falsy value.
|
---|
18 | * @param {*} x An object to test with the `pred` function and
|
---|
19 | * pass to `whenFalseFn` if necessary.
|
---|
20 | * @return {*} Either `x` or the result of applying `x` to `whenFalseFn`.
|
---|
21 | * @see R.ifElse, R.when, R.cond
|
---|
22 | * @example
|
---|
23 | *
|
---|
24 | * let safeInc = R.unless(R.isNil, R.inc);
|
---|
25 | * safeInc(null); //=> null
|
---|
26 | * safeInc(1); //=> 2
|
---|
27 | */
|
---|
28 |
|
---|
29 |
|
---|
30 | var unless =
|
---|
31 | /*#__PURE__*/
|
---|
32 | _curry3(function unless(pred, whenFalseFn, x) {
|
---|
33 | return pred(x) ? x : whenFalseFn(x);
|
---|
34 | });
|
---|
35 |
|
---|
36 | module.exports = unless; |
---|
Note:
See
TracBrowser
for help on using the repository browser.