range-checker
v1.0.0
Published
A simple utility to check if a number is within a specified range.
Downloads
6
Maintainers
Readme
Range Checker
A simple utility to check if a number is within a specified range.
Installation
npm install range-checker
Usage
import isInRange from 'range-checker';
// Check if a number is within the range
console.log(isInRange(30, { start: 10, end: 100 })); //=> true
API
isInRange(number, options)
Check if a number is within a given range.
number
: The number to check.options
: An object containing options for specifying the range.start
(optional): The start of the range. Default is0
.end
: The end of the range.
Returns true
if the number is within the range, false
otherwise.
Examples
import isInRange from 'range-checker';
// Check if a number is within different ranges
console.log(isInRange(30, { end: 100 })); //=> true
console.log(isInRange(30, { start: 100, end: 10 })); //=> true
console.log(isInRange(30, { end: 10 })); //=> false
License
This project is licensed under the MIT License - see the LICENSE file for details.