Range components, intended to replicate the ranges available in Swift.
Expresses a range like 1..<10
- ie '1 to 10, exclusive'.
import { Range } from 'rr-range'
const myRange = Range.fromToLessThan(1, 10)
myRange.containsValue(9.9) // true
myRange.containsValue(1) // true
myRange.containsValue(10) // false
myRange.containsValue(0) // false
Constructs a new range, with the given lower and upper bounds.
Constructs an empty range for use with numbers.
Constructs an empty range for use with dates.
Returns true if the value is within the current range.
Returns true if the other range entirely fits within the current range.
Returns true if the other range overlaps with the current range at all.
Returns a new range that spans both the current range and the other range.
Throws if the ranges do not overlap.
Returns true if the two range objects cover the exact same range.
Returns a representation of the range like 1..<10
Expresss a range like 1...10
- ie '1 to 10, inclusive'.
import { ClosedRange } from 'rr-range'
const myRange = ClosedRange.fromTo(1, 10)
myRange.containsValue(10) // true
myRange.containsValue(1) // true
myRange.containsValue(10.1) // false
myRange.containsValue(0) // false
Constructs a new range, with the given lower and upper bounds.
Returns true if the value is within the current range.
Returns true if the other range entirely fits within the current range.
Returns true if the other range overlaps with the current range at all.
Returns a new range that spans both the current range and the other range.
Throws if the ranges do not overlap.
Returns true if the two range objects cover the exact same range.
Returns a representation of the range like 1...10