number/clamp
v0.0.1
0.0.1
Collaborators
Gravatar for undefined
0
MIT
PUBLIC
0
0     DEPENDENCIES
BuildPass

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

Use number/clamp in your project
npm i @bit/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