Given a multi-part range (think day/hour/minute or chapter/verse), check to see if a value is within the range.
const rangeStart = 10 21const rangeEnd = 12 2 // => false // => true // => true // => false
Ranges can have as many parts as you need.
const day = 4const hour = 12const minute = 55 // => true
withinRange(rangeStart, rangeEnd, value)
All arguments must be arrays of integers, all with the same number of elements.
Returns true or false.
Comparisons are inclusive.
withinRange.relative(rangeStart, rangeEnd, value)
Reminiscent of the Array.prototype.sort
parameter.
Returns -1 if value
is less than rangeStart
.
Returns 1 if value
is greater than rangeEnd
.
Returns 0 if value
is within the range.
withinRange // => withinRange.LESS_THAN_STARTwithinRange // => withinRange.WITHINwithinRange // => withinRange.GREATER_THAN_END withinRangeLESS_THAN_START // => -1withinRangeWITHIN // => 0withinRangeGREATER_THAN_END // => 1