Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

mima

1.0.2 • Public • Published

mima

Make sure that a number is between min and max

Build Status Test Coverage

bitHound Code bitHound Overall Score bitHound Dependencies bitHound Dev Dependencies License: MIT

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

Install

npm i mima

DownloadsWeekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • avatar