Socket
Book a DemoInstallSign in
Socket

in-range

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

in-range

Check if a number is in a given range

latest
Source
npmnpm
Version
3.0.0
Version published
Weekly downloads
5.5K
11.25%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

in

FAQs

Package last updated on 23 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts