UNPKG

@fivem-ts/shared

Version:

FiveM Typescript wrapper shared part

23 lines (22 loc) 524 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.clamp = clamp; /** * Clamps a number to a specified range. * * @example * ```ts * clamp(5, 1, 10); // 5 * clamp(0, 1, 10); // 1 * clamp(15, 1, 10); // 10 * ``` * * @param {number} num - The number to clamp. * @param {number} min - The minimum value. * @param {number} max - The maximum value. * * @return {number} The clamped value. */ function clamp(num, min, max) { return num <= min ? min : num >= max ? max : num; }