1.0.2 • Published 7 years ago
mima v1.0.2
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 = require('mima')
mima(0, -100, 1) // 0
// because -100 is smaller than 0
mima(0, 1, 2) // 1
// because 1 is between 0 and 2
mima(0, 0.3, 1) // 0.3
// because 0.3 is between 0 and 1
mima(5, 100, 10) // 10
// because 100 is bigger than 10