Socket
Book a DemoInstallSign in
Socket

is-contained

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

is-contained

Check whether one or more values are contained within an interval.

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

is-contained

Check whether one or more values are contained within an interval.

Installation

npm i is-contained

Usage

A very common task encountered in programming is checking whether one or more values are contained within an interval. For instance, collision detection in games often involves checking whether a sprite's position lies within a certain hitbox. This package allows you to do all this without the annoying boilerplate.

import isContained from 'is-contained'


isContained(5, min=0) // returns true

isContained(5, min=5) // returns true

isContained(5, min=6) // returns false

isContained(5, min=0, max=4) // returns false

isContained([1, 2, 3], min=0, max=5) // returns true

isContained([1, 2, 8], min=0, max=5) // returns false

Keywords

interval

FAQs

Package last updated on 03 Feb 2023

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