The type the target range contains.
A standard comparator.
It's expected to return 0 upon equality, a negative number if a < b, and a positive if a > b.
Care needs to be taken around handling infinity cases, since arithmetic operations on Infinity
always return NaN
, thus potentially breaking this interface. It is thus recommended to handle
equality cases separately by returning an explicit 0
.
Should return true for both positive and negative infinity.
It is possible to have less than two infinities, i.e. it's theoretically possible (albeit not totally practical) to build a range over a field of 0..Infinity, or -Infinity..0.
Generated using TypeDoc
An interface representing the knowledge required to create ranges of arbitrary type
T
.This interface is required to construct ranges over custom user-provided types.
Range
usesNumberSpec
by default, so there's no need to specify this spec for number-compatible types, e.g. ones that havevalueOf(): number
implemented.See
Range
andRangeSet
constructor methods for examples of how this spec is used.It is recommended to extend
AbstractRangeSpec
for user-defined ranges.