source: node_modules/ramda-adjunct/lib/argsPass.js

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: 2.2 KB
RevLine 
[d24f17c]1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _ramda = require("ramda");
6var _list = _interopRequireDefault(require("./list"));
7var _isTruthy = _interopRequireDefault(require("./isTruthy"));
8function _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 */
39var argsPass = (0, _ramda.curry)(function (combiningPredicate, predicates) {
40 return (0, _ramda.useWith)((0, _ramda.compose)(combiningPredicate(_isTruthy["default"]), _list["default"]), predicates);
41});
42var _default = argsPass;
43exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.