Sha256: 72483dd199939b063097198b572261b71241eda9e7d7c03beb646a239c75d8f8

Contents?: true

Size: 1.22 KB

Versions: 265

Compression:

Stored size: 1.22 KB

Contents

var baseInRange = require('./_baseInRange'),
    toFinite = require('./toFinite'),
    toNumber = require('./toNumber');

/**
 * Checks if `n` is between `start` and up to, but not including, `end`. If
 * `end` is not specified, it's set to `start` with `start` then set to `0`.
 * If `start` is greater than `end` the params are swapped to support
 * negative ranges.
 *
 * @static
 * @memberOf _
 * @since 3.3.0
 * @category Number
 * @param {number} number The number to check.
 * @param {number} [start=0] The start of the range.
 * @param {number} end The end of the range.
 * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
 * @see _.range, _.rangeRight
 * @example
 *
 * _.inRange(3, 2, 4);
 * // => true
 *
 * _.inRange(4, 8);
 * // => true
 *
 * _.inRange(4, 2);
 * // => false
 *
 * _.inRange(2, 2);
 * // => false
 *
 * _.inRange(1.2, 2);
 * // => true
 *
 * _.inRange(5.2, 4);
 * // => false
 *
 * _.inRange(-3, -2, -6);
 * // => true
 */
function inRange(number, start, end) {
  start = toFinite(start);
  if (end === undefined) {
    end = start;
    start = 0;
  } else {
    end = toFinite(end);
  }
  number = toNumber(number);
  return baseInRange(number, start, end);
}

module.exports = inRange;

Version data entries

265 entries across 263 versions & 30 rubygems

Version Path
trusty-cms-6.3.1 node_modules/lodash/inRange.js
immosquare-cleaner-0.1.51 node_modules/lodash/inRange.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/inRange.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/inRange.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/inRange.js
immosquare-cleaner-0.1.50 node_modules/lodash/inRange.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/inRange.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/inRange.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/inRange.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/inRange.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/inRange.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/lodash/inRange.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/lodash/inRange.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/lodash/inRange.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/lodash/inRange.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/lodash/inRange.js
immosquare-cleaner-0.1.49 node_modules/lodash/inRange.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/lodash/inRange.js
immosquare-cleaner-0.1.48 node_modules/lodash/inRange.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/lodash/inRange.js