source: imaps-frontend/node_modules/lodash-es/inRange.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[d565449]1import baseInRange from './_baseInRange.js';
2import toFinite from './toFinite.js';
3import toNumber from './toNumber.js';
4
5/**
6 * Checks if `n` is between `start` and up to, but not including, `end`. If
7 * `end` is not specified, it's set to `start` with `start` then set to `0`.
8 * If `start` is greater than `end` the params are swapped to support
9 * negative ranges.
10 *
11 * @static
12 * @memberOf _
13 * @since 3.3.0
14 * @category Number
15 * @param {number} number The number to check.
16 * @param {number} [start=0] The start of the range.
17 * @param {number} end The end of the range.
18 * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
19 * @see _.range, _.rangeRight
20 * @example
21 *
22 * _.inRange(3, 2, 4);
23 * // => true
24 *
25 * _.inRange(4, 8);
26 * // => true
27 *
28 * _.inRange(4, 2);
29 * // => false
30 *
31 * _.inRange(2, 2);
32 * // => false
33 *
34 * _.inRange(1.2, 2);
35 * // => true
36 *
37 * _.inRange(5.2, 4);
38 * // => false
39 *
40 * _.inRange(-3, -2, -6);
41 * // => true
42 */
43function inRange(number, start, end) {
44 start = toFinite(start);
45 if (end === undefined) {
46 end = start;
47 start = 0;
48 } else {
49 end = toFinite(end);
50 }
51 number = toNumber(number);
52 return baseInRange(number, start, end);
53}
54
55export default inRange;
Note: See TracBrowser for help on using the repository browser.