Returns true if range 'a' is within or same as range 'b'. Returns false if not or if either/both ranges are undefined
rangeIsWithin({ min: 5, max: 10 }, { min: 0, max: 10 }); // truerangeIsWithin({ min: 5, max: 10 }, { min: 6, max: 20 }); // false Copy
rangeIsWithin({ min: 5, max: 10 }, { min: 0, max: 10 }); // truerangeIsWithin({ min: 5, max: 10 }, { min: 6, max: 20 }); // false
By default the matching is inclusive, in that a could share a min/max with b. If you want to check whether a is strictly within b, with a higher min and lower max, set exclusive to true.
a
b
exclusive
rangeIsWithin({ min: 5, max: 10 }, { min: 0, max: 10 }, true); // falserangeIsWithin({ min: 5, max: 9 }, { min: 0, max: 10 }, true); // true Copy
rangeIsWithin({ min: 5, max: 10 }, { min: 0, max: 10 }, true); // falserangeIsWithin({ min: 5, max: 9 }, { min: 0, max: 10 }, true); // true
If either a or b is undefined, the function returns false.
Range
Parent
If true,
Returns true if range 'a' is within or same as range 'b'. Returns false if not or if either/both ranges are undefined
By default the matching is inclusive, in that
acould share a min/max withb. If you want to check whetherais strictly withinb, with a higher min and lower max, setexclusiveto true.If either
aorbis undefined, the function returns false.