UNPKG

vevet

Version:

Vevet is a JavaScript library for creative development that simplifies crafting rich interactions like split text animations, carousels, marquees, preloading, and more.

34 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.inRange = inRange; /** * Determines if a value lies within a specified range (inclusive of the range boundaries). * * @param {number} value - The value to check. * @param {number} [min=0] - The minimum boundary of the range. * @param {number} [max=1] - The maximum boundary of the range. * @returns {boolean} - `true` if the value is within the range (inclusive), otherwise `false`. * * @group Utils * * @example * inScope(0, 0, 1); * // => true (0 is within the range [0, 1]) * * inScope(1, 0, 1); * // => true (1 is within the range [0, 1]) * * inScope(2, 0, 1); * // => false (2 is outside the range [0, 1]) * * inScope(-1, 0, 1); * // => false (-1 is outside the range [0, 1]) */ function inRange(value, min, max) { if (min === void 0) { min = 0; } if (max === void 0) { max = 1; } var realMin = Math.min(min, max); var realMax = Math.max(min, max); return value >= realMin && value <= realMax; } //# sourceMappingURL=inRange.js.map