Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 791 Bytes

README.md

File metadata and controls

38 lines (25 loc) · 791 Bytes

🌹 between

🛑 Use Lodash inRange instead.

between tests if a numeral value is between two bounds.

So instead of writing this:

const x = 50
if (x >= 10 && x <= 100)

You can now use:

if (between(x, 10, 100))

The bounds are compared inclusively by default. For an exclusive comparison, use the last parameter, which can be exclude, exclude-lower, or exclude-upper.

import between from '@sharyn/util/between'
// or import { between } from '@sharyn/util'

const x = 50
between(x, 10, 100) // true

between(10, 10, 100) // true
between(100, 10, 100) // true

between(10, 10, 100, 'exclude-lower') // false
between(100, 10, 100, 'exclude-upper') // false

between(10, 10, 100, 'exclude') // false
between(100, 10, 100, 'exclude') // false