@azizbecha/strkit
Version:
strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.
15 lines • 442 B
JavaScript
/**
* Clamps a number between a minimum and maximum value.
* @param value - The number to clamp.
* @param min - The minimum allowed value.
* @param max - The maximum allowed value.
* @returns The clamped value.
* @example
* clamp(15, 0, 10); // 10
* clamp(-5, 0, 10); // 0
* clamp(5, 0, 10); // 5
*/
export default function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
//# sourceMappingURL=clamp.js.map