[d24f17c] | 1 | var _curry2 =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./internal/_curry2.js");
|
---|
| 4 |
|
---|
| 5 | var _isFunction =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./internal/_isFunction.js");
|
---|
| 8 |
|
---|
| 9 | var and =
|
---|
| 10 | /*#__PURE__*/
|
---|
| 11 | require("./and.js");
|
---|
| 12 |
|
---|
| 13 | var lift =
|
---|
| 14 | /*#__PURE__*/
|
---|
| 15 | require("./lift.js");
|
---|
| 16 | /**
|
---|
| 17 | * A function which calls the two provided functions and returns the `&&`
|
---|
| 18 | * of the results.
|
---|
| 19 | * It returns the result of the first function if it is false-y and the result
|
---|
| 20 | * of the second function otherwise. Note that this is short-circuited,
|
---|
| 21 | * meaning that the second function will not be invoked if the first returns a
|
---|
| 22 | * false-y value.
|
---|
| 23 | *
|
---|
| 24 | * In addition to functions, `R.both` also accepts any fantasy-land compatible
|
---|
| 25 | * applicative functor.
|
---|
| 26 | *
|
---|
| 27 | * @func
|
---|
| 28 | * @memberOf R
|
---|
| 29 | * @since v0.12.0
|
---|
| 30 | * @category Logic
|
---|
| 31 | * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean)
|
---|
| 32 | * @param {Function} f A predicate
|
---|
| 33 | * @param {Function} g Another predicate
|
---|
| 34 | * @return {Function} a function that applies its arguments to `f` and `g` and `&&`s their outputs together.
|
---|
| 35 | * @see R.either, R.allPass, R.and
|
---|
| 36 | * @example
|
---|
| 37 | *
|
---|
| 38 | * const gt10 = R.gt(R.__, 10)
|
---|
| 39 | * const lt20 = R.lt(R.__, 20)
|
---|
| 40 | * const f = R.both(gt10, lt20);
|
---|
| 41 | * f(15); //=> true
|
---|
| 42 | * f(30); //=> false
|
---|
| 43 | *
|
---|
| 44 | * R.both(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(false)
|
---|
| 45 | * R.both([false, false, 'a'], [11]); //=> [false, false, 11]
|
---|
| 46 | */
|
---|
| 47 |
|
---|
| 48 |
|
---|
| 49 | var both =
|
---|
| 50 | /*#__PURE__*/
|
---|
| 51 | _curry2(function both(f, g) {
|
---|
| 52 | return _isFunction(f) ? function _both() {
|
---|
| 53 | return f.apply(this, arguments) && g.apply(this, arguments);
|
---|
| 54 | } : lift(and)(f, g);
|
---|
| 55 | });
|
---|
| 56 |
|
---|
| 57 | module.exports = both; |
---|