source: node_modules/ramda-adjunct/src/inRange.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: 982 bytes
RevLine 
[d24f17c]1import { ifElse, curry, useWith, both, gte, lte, gt } from 'ramda';
2
3const inRangeImp = ifElse(
4 gte,
5 () => {
6 throw new Error(
7 'low must not be greater than high in inRange(low, high, value)'
8 );
9 },
10 useWith(both, [lte, gt])
11);
12
13/**
14 * Checks if `value` is between `low` and up to but not including `high`.
15 *
16 * @func inRange
17 * @memberOf RA
18 * @since {@link https://char0n.github.io/ramda-adjunct/2.7.0|v2.7.0}
19 * @category Relation
20 * @sig Number -> Number -> Number -> Boolean
21 * @param {number} low Start of the range
22 * @param {number} high The end of the range
23 * @param {number} value The value to test
24 * @return {boolean}
25 * @throws {Error} When `low` is greater than or equal to `high`
26 * @example
27 *
28 * RA.inRange(0, 5, 3); //=> true
29 * RA.inRange(0, 5, 0); //=> true
30 * RA.inRange(0, 5, 4); //=> true
31 * RA.inRange(0, 5, 5); //=> false
32 * RA.inRange(0, 5, -1); //=> false
33 */
34export default curry((low, high, value) => inRangeImp(low, high)(value));
Note: See TracBrowser for help on using the repository browser.