Creates a new Interval.
The minimum value (inclusive)
Optionalmax: numberThe maximum value (inclusive), or undefined for unbounded
StaticfromCreates an interval from a range specification.
The start of the range (inclusive)
Optionalend: numberThe end of the range (inclusive), or undefined for unbounded
A new Interval
StaticexactlyCreates an interval for exactly n occurrences.
The exact count
A new Interval with min = max = n
StaticatCreates an interval for at least n occurrences.
The minimum count
A new Interval with min = n and no maximum
StaticatCreates an interval for at most n occurrences.
The maximum count
A new Interval with min = 0 and max = n
StaticzeroCreates an interval for zero or more occurrences (0..).
A new Interval representing *
StaticoneCreates an interval for one or more occurrences (1..).
A new Interval representing +
StaticzeroCreates an interval for zero or one occurrence (0..=1).
A new Interval representing ?
Returns the minimum value of the interval.
Returns the maximum value of the interval, or undefined if unbounded.
Checks if the given count falls within this interval.
The count to check
true if count is within the interval
Checks if the interval represents a single value (i.e., min equals max).
Checks if the interval is unbounded (i.e., has no maximum value).
Returns a string representation of the interval using shorthand notation where applicable.
The shorthand notation string
Returns a string representation using range notation.
Represents an inclusive interval with a minimum value and an optional maximum value.
When the maximum is
undefined, the interval is considered unbounded above.Example