clamp

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
989 B
Restricts a number to be within a range.
1 contributor
Install clamp as a package?
Copied
npm i @bit/justin-capalbo.ramda.clamp
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
modifieddraft
chevron_left
chevron_right
clamp (
minimum:Number,
maximum:Number,
value:Number
) : Number

Restricts a number to be within a range.

Also works for other ordered types such as Strings and Dates.

Example
R.clamp(1, 10, -5) // => 1
     R.clamp(1, 10, 15) // => 10
     R.clamp(1, 10, 4)  // => 4
Arguments
minimum: Number

The lower limit of the clamp (inclusive)

maximum: Number

The upper limit of the clamp (inclusive)

value: Number

Value to be clamped

Returns
Number

Returns `minimum` when `val < minimum`, `maximum` when `val > maximum`, returns `val` otherwise

Help and resources