Skip to content

A simple utility to check if a number is within a specified range.

License

Notifications You must be signed in to change notification settings

vincenzomaritato/range-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Range Checker

GitHub license

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 is 0.
    • 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.

About

A simple utility to check if a number is within a specified range.

Resources

License

Code of conduct

Stars

Watchers

Forks