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

3.0.0 • Public • Published

in-range

Check if a number is in a given range

Install

$ npm install in-range

Usage

import inRange from 'in-range';

inRange(30, {end: 100}); // 0..100
//=> true

inRange(30, {start: 10, end: 100}); // 10..100
//=> true

inRange(30, {start: 100, end: 10}); // 10..100
//=> true

inRange(30, {end: 10}); // 0..10
//=> false

// Any input can be a BigInt
inRange(30n, {start: 100n, end: 10}); // 10..100
//=> true

API

inRange(number, range)

number

Type: number | BigInt

Number to check.

range

Type: object

start?

Type: number | BigInt
Default: 0

Start of the range.

end

Type: number | BigInt

End of the range.

Package Sidebar

Install

npm i in-range

Weekly Downloads

2,165

Version

3.0.0

License

MIT

Unpacked Size

3.66 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus