Limit a number between a min and max value.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitignore
.travis.yml
LICENSE
README.md
package.json

README.md

limit-number

Travis Build Status Coverage Status Dependencies

Limit a number between a min and max value.

Install

npm install limit-number

Usage

const limit = require('limit-number')

limit(0, 10, 5) // 5
limit(0, 10, 15) // 10
limit(0, 10, -5) // 0

Parameters

  • min {Number} Min number.
  • max {Number} Max number.
  • num {Number} Number.

Returns

  • {Number} Limited number.