is-contained

1.0.2 • Public • Published

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

Package Sidebar

Install

npm i is-contained

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

1.79 kB

Total Files

3

Last publish

Collaborators

  • oelin