mima
Make sure that a number is between min and max
Install
npm i mima --save
mima(min, x, max)
- min
<number|null|undefined>
- x
<number>
- max
<number|null|undefined>
If x
is smaller than min
then min
is returned.
If x
is between min
and max
then x
is returned.
If x
is bigger than max
then max
is returned.
Example
const mima = // 0// because -100 is smaller than 0 // 1// because 1 is between 0 and 2 // 0.3// because 0.3 is between 0 and 1 // 10// because 100 is bigger than 10