1 | "use strict";
|
---|
2 |
|
---|
3 | exports.__esModule = true;
|
---|
4 | exports["default"] = void 0;
|
---|
5 | var _ramda = require("ramda");
|
---|
6 | var _list = _interopRequireDefault(require("./list"));
|
---|
7 | var _isTruthy = _interopRequireDefault(require("./isTruthy"));
|
---|
8 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
---|
9 | /**
|
---|
10 | * Takes a combining predicate and a list of functions and returns a function which will map the
|
---|
11 | * arguments it receives to the list of functions and returns the result of passing the values
|
---|
12 | * returned from each function to the combining predicate. A combining predicate is a function that
|
---|
13 | * combines a list of Boolean values into a single Boolean value, such as `R.any` or `R.all`. It
|
---|
14 | * will test each value using `RA.isTruthy`, meaning the functions don't necessarily have to be
|
---|
15 | * predicates.
|
---|
16 | *
|
---|
17 | * The function returned is curried to the number of functions supplied, and if called with more
|
---|
18 | * arguments than functions, any remaining arguments are passed in to the combining predicate
|
---|
19 | * untouched.
|
---|
20 | *
|
---|
21 | * @func argsPass
|
---|
22 | * @memberOf RA
|
---|
23 | * @since {@link https://char0n.github.io/ramda-adjunct/2.7.0|v2.7.0}
|
---|
24 | * @category Logic
|
---|
25 | * @sig ((* -> Boolean) -> [*] -> Boolean) -> [(* -> Boolean), ...] -> (*...) -> Boolean
|
---|
26 | * @param {Function} combiningPredicate The predicate used to combine the values returned from the
|
---|
27 | * list of functions
|
---|
28 | * @param {Array} functions List of functions
|
---|
29 | * @return {boolean} Returns the combined result of mapping arguments to functions
|
---|
30 | * @example
|
---|
31 | *
|
---|
32 | * RA.argsPass(R.all, [RA.isArray, RA.isBoolean, RA.isString])([], false, 'abc') //=> true
|
---|
33 | * RA.argsPass(R.all, [RA.isArray, RA.isBoolean, RA.isString])([], false, 1) //=> false
|
---|
34 | * RA.argsPass(R.any, [RA.isArray, RA.isBoolean, RA.isString])({}, 1, 'abc') //=> true
|
---|
35 | * RA.argsPass(R.any, [RA.isArray, RA.isBoolean, RA.isString])({}, 1, false) //=> false
|
---|
36 | * RA.argsPass(R.none, [RA.isArray, RA.isBoolean, RA.isString])({}, 1, false) //=> true
|
---|
37 | * RA.argsPass(R.none, [RA.isArray, RA.isBoolean, RA.isString])({}, 1, 'abc') //=> false
|
---|
38 | */
|
---|
39 | var argsPass = (0, _ramda.curry)(function (combiningPredicate, predicates) {
|
---|
40 | return (0, _ramda.useWith)((0, _ramda.compose)(combiningPredicate(_isTruthy["default"]), _list["default"]), predicates);
|
---|
41 | });
|
---|
42 | var _default = argsPass;
|
---|
43 | exports["default"] = _default; |
---|