source: node_modules/ramda-adjunct/src/notBoth.js@ 65b6638

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

Initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1import { curry, compose, complement, both } from 'ramda';
2
3/* eslint-disable max-len */
4/**
5 * A function which calls the two provided functions and returns the complement of `&&`ing the
6 * results.
7 * It returns true if the first function is false-y and the complement of the second function
8 * otherwise. Note that this is short-circuited, meaning that the second function will not be
9 * invoked if the first returns a false-y value. In short it will return true unless both predicates
10 * return true.
11 *
12 * In addition to functions, `RA.notBoth` also accepts any fantasy-land compatible
13 * applicative functor.
14 *
15 * @func notBoth
16 * @memberOf RA
17 * @since {@link https://char0n.github.io/ramda-adjunct/2.3.0|v2.3.0}
18 * @category Logic
19 * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean)
20 * @param {Function} f A predicate
21 * @param {Function} g Another predicate
22 * @return {Function} Returns a function that applies its arguments to `f` and `g` and returns the complement of `&&`ing their outputs together.
23 * @see {@link http://ramdajs.com/docs/#both|R.both}
24 * @example
25 *
26 * const gt10 = R.gt(R.__, 10)
27 * const even = (x) => x % 2 === 0;
28 * const f = RA.notBoth(gt10, even);
29 *
30 * f(12); //=> false
31 * f(8); //=> true
32 * f(11); //=> true
33 * f(9); //=> true
34 */
35/* eslint-enable max-len */
36const notBoth = curry(compose(complement, both));
37
38export default notBoth;
Note: See TracBrowser for help on using the repository browser.