Share your code. Components are building blocks, you are the architect.

number/clamp
v1.0.0
1.0.0
0.0.1
MIT
PUBLIC
1
0     DEPENDENCIES
Build: pass
BuildPass
Build Status: pass
Returns a number whose value is limited to the given range.
bit
Contributors
Gravatar for undefinedGravatar for undefined
1

Please configure Bit as a scoped registry to install components with NPM.Learn more

npm config set '@bit:registry' https://node.bitsrc.io
Use number/clamp in your project
npm i @bit/bit.utils.number.clamp
Copied

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