Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 29x 1x 28x 1x 27x | /** * @public * @class utils */ /** * Ensures that a number is not less than or greater than a given min and max. * * @public * @method withinRange * * @param {number} value The value that should be checked/returned if within * given range. * * @param {number} min The minimum allowed value of the `value` param. If `value` * is less than this value, this value will be returned instead. * * @param {number} max The maximum allowed value of the `value` param. If `value` * is greater than this value, this value will be returned instead. */ export default function withinRange(value, min, max) { if (value < min) { return min; } else if (value > max) { return max; } else { return value; } } |