1. in-range
Check if a number is in a given range
in-range
Package: in-range
Created by: sindresorhus
Last modified: Sun, 09 Jul 2023 22:10:42 GMT
Version: 3.0.0
License: MIT
Downloads: 11,267
Repository: https://github.com/sindresorhus/in-range

Install

npm install in-range
yarn add in-range

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.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin