1.0.2 • Published 1 year ago

is-contained v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago