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.

28 lines 920 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.clamp = clamp; /** * Restricts a value to lie within a specified range. * * Ensures that `value` is no less than `min` and no greater than `max`. * * @param {number} value - The input value to be clamped. * @param {number} [min=0] - The lower bound of the range (default is 0). * @param {number} [max=1] - The upper bound of the range (default is 1). * @returns {number} - The clamped value within the range [min, max]. * * @group Utils * * @example * clamp(1.5, 0.1, 0.9); // 0.9 * clamp(0.001, 0.1, 0.9); // 0.1 * clamp(0.5, 0, 1); // 0.5 */ function clamp(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 Math.max(realMin, Math.min(value, realMax)); } //# sourceMappingURL=clamp.js.map