is-in-range
v1.0.1
Published
Checks if a number is within a range in the format "1-10" or "3,5-7,9"
Downloads
4
Maintainers
Readme
is-in-range
Checks if a number is within a string range in the format "1-10" or "3,5-7,9"
A range can be like the following:
1-10
10-1
23
23,1-10
23, 1-10
1.5-3.7
Only positive numbers are allowed.
Installing
npm install is-in-range
Example usage
var inRange = require('is-in-range');
inRange('1-10', 5) // True
inRange('1-10', 11) // False