Like
Install clamp as a package?
Copied
npm i @bit/bit.utils.number.clamp
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example modifieddraft
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
and packages in Bit or NPM to the example. any of the 1 million componentstoggle layout
No preview available
chevron_left
chevron_right
clamp (
value:
number
,min:
number
,max:
) : number
number
Returns a number whose value is limited to the given range.
Example
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 range | Pass |