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:
1020 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | exports.__esModule = true;
|
---|
| 4 | exports["default"] = void 0;
|
---|
| 5 | var _ramda = require("ramda");
|
---|
| 6 | /**
|
---|
| 7 | * Returns the second argument if predicate function returns `true`,
|
---|
| 8 | * otherwise the third argument is returned.
|
---|
| 9 | *
|
---|
| 10 | * @func defaultWhen
|
---|
| 11 | * @memberOf RA
|
---|
| 12 | * @since {@link https://char0n.github.io/ramda-adjunct/2.2.0|v2.2.0}
|
---|
| 13 | * @category Logic
|
---|
| 14 | * @sig (a -> Boolean) -> b -> a -> a | b
|
---|
| 15 | * @param {!function} predicate The predicate function
|
---|
| 16 | * @param {*} defaultVal The default value
|
---|
| 17 | * @param {*} val `val` will be returned instead of `defaultVal` if predicate returns false
|
---|
| 18 | * @return {*} The `val` if predicate returns `false`, otherwise the default value
|
---|
| 19 | * @see {@link http://ramdajs.com/docs/#defaultTo|R.defaultTo}
|
---|
| 20 | * @example
|
---|
| 21 | *
|
---|
| 22 | * RA.defaultWhen(RA.isNull, 1, null); // => 1
|
---|
| 23 | * RA.defaultWhen(RA.isNull, 1, 2); // => 2
|
---|
| 24 | */
|
---|
| 25 | var defaultWhen = (0, _ramda.curry)(function (predicate, defaultVal, val) {
|
---|
| 26 | return predicate(val) ? defaultVal : val;
|
---|
| 27 | });
|
---|
| 28 | var _default = defaultWhen;
|
---|
| 29 | exports["default"] = _default; |
---|
Note:
See
TracBrowser
for help on using the repository browser.