source: node_modules/ramda-adjunct/src/neither.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: 1.4 KB
RevLine 
[d24f17c]1import { curry, compose, complement, either } 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 false if the first function is truth-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 truth-y value. In short it will return true if neither predicate
10 * returns true.
11 *
12 * In addition to functions, `RA.neither` also accepts any fantasy-land compatible
13 * applicative functor.
14 *
15 * @func neither
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/#either|R.either}, {@link http://ramdajs.com/docs/#or|R.or}
24 * @example
25 *
26 * const gt10 = R.gt(R.__, 10)
27 * const even = (x) => x % 2 === 0;
28 * const f = RA.neither(gt10, even);
29 *
30 * f(12); //=> false
31 * f(8); //=> false
32 * f(11); //=> false
33 * f(9); //=> true
34 */
35/* eslint-enable max-len */
36const neither = curry(compose(complement, either));
37
38export default neither;
Note: See TracBrowser for help on using the repository browser.