https://github.com/robojones/mima
Make sure that a number is between min and max
https://github.com/robojones/mima
between javascript maximum minimum nodejs npm number
Last synced: 7 months ago
JSON representation
Make sure that a number is between min and max
- Host: GitHub
- URL: https://github.com/robojones/mima
- Owner: robojones
- License: mit
- Created: 2017-08-18T20:48:08.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-04T16:27:09.000Z (over 8 years ago)
- Last Synced: 2025-06-14T03:37:19.643Z (8 months ago)
- Topics: between, javascript, maximum, minimum, nodejs, npm, number
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/mima
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mima
Make sure that a number is between min and max
[](https://travis-ci.org/robojones/mima)
[](https://codeclimate.com/github/robojones/mima/coverage)
[](https://www.bithound.io/github/robojones/mima)
[](https://www.bithound.io/github/robojones/mima)
[](https://www.bithound.io/github/robojones/mima/master/dependencies/npm)
[](https://www.bithound.io/github/robojones/mima/master/dependencies/npm)
[](https://opensource.org/licenses/MIT)
## Install
```bash
npm i mima --save
```
## mima(min, x, max)
- __min__ ``
- __x__ ``
- __max__ ``
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
```javascript
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
```