range-checker
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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.

Package Sidebar

Install

npm i range-checker

Weekly Downloads

5

Version

1.0.0

License

MIT

Unpacked Size

3.42 kB

Total Files

4

Last publish

Collaborators

  • vincenzomaritato