source: node_modules/ramda-adjunct/es/argsPass.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[d24f17c]1import { useWith, curry, compose } from 'ramda';
2import list from './list';
3import isTruthy from './isTruthy';
4
5/**
6 * Takes a combining predicate and a list of functions and returns a function which will map the
7 * arguments it receives to the list of functions and returns the result of passing the values
8 * returned from each function to the combining predicate. A combining predicate is a function that
9 * combines a list of Boolean values into a single Boolean value, such as `R.any` or `R.all`. It
10 * will test each value using `RA.isTruthy`, meaning the functions don't necessarily have to be
11 * predicates.
12 *
13 * The function returned is curried to the number of functions supplied, and if called with more
14 * arguments than functions, any remaining arguments are passed in to the combining predicate
15 * untouched.
16 *
17 * @func argsPass
18 * @memberOf RA
19 * @since {@link https://char0n.github.io/ramda-adjunct/2.7.0|v2.7.0}
20 * @category Logic
21 * @sig ((* -> Boolean) -> [*] -> Boolean) -> [(* -> Boolean), ...] -> (*...) -> Boolean
22 * @param {Function} combiningPredicate The predicate used to combine the values returned from the
23 * list of functions
24 * @param {Array} functions List of functions
25 * @return {boolean} Returns the combined result of mapping arguments to functions
26 * @example
27 *
28 * RA.argsPass(R.all, [RA.isArray, RA.isBoolean, RA.isString])([], false, 'abc') //=> true
29 * RA.argsPass(R.all, [RA.isArray, RA.isBoolean, RA.isString])([], false, 1) //=> false
30 * RA.argsPass(R.any, [RA.isArray, RA.isBoolean, RA.isString])({}, 1, 'abc') //=> true
31 * RA.argsPass(R.any, [RA.isArray, RA.isBoolean, RA.isString])({}, 1, false) //=> false
32 * RA.argsPass(R.none, [RA.isArray, RA.isBoolean, RA.isString])({}, 1, false) //=> true
33 * RA.argsPass(R.none, [RA.isArray, RA.isBoolean, RA.isString])({}, 1, 'abc') //=> false
34 */
35var argsPass = curry(function (combiningPredicate, predicates) {
36 return useWith(compose(combiningPredicate(isTruthy), list), predicates);
37});
38export default argsPass;
Note: See TracBrowser for help on using the repository browser.