bit/utils/number/clamp

pass
Public
Gravatar for undefined
0 Likes

Returns a number whose value is limited to the given range.

bit import bit.utils/number/clamp

clamp (value:number, min:number, max:number) : number

Returns a number whose value is limited to the given range.

Example

clamp(50, 5, 10) // => 5

Arguments

value: number

The value to be clamped

min: number

The lower boundary of the output range

max: number

The upper boundary of the output range

Returns

number

A number in the range [min, max]

Test Summary

number/clamp should return the max number (10)Pass
number/clamp should return the min number (5)Pass
number/clamp should return the passed number as its within rangePass