mathClamp
type: function
since: v2.10.0
since: v2.10.0
The mathClamp function Clamps a number to be within a specified range
Usage
import { mathClamp } from '@mustib/utils'
mathClamp(1,2,3) // 2mathClamp(2,1,3) // 2mathClamp(1,3,2) // 2Definition
function mathClamp( minValue: number, currentValue: number, maxValue: number): numberParameters
-
minValuetype minValue = number;- The minimum allowed value for the number.
-
currentValuetype currentValue = number;- The current value of the number.
-
currentValuetype currentValue = number;- The maximum allowed value for the number.
Returns
type T = number;- The clamped value, which is within the specified range [minValue, maxValue]