Skip to main content

type Range<T>

A range definition for any type of (orderable) value. If a start or end is defined, a tuple can be used where the second item is a boolean indicating whether that end is inclusive (true) or exclusive (false). A Range of type T can have one of the following forms:

  • { end: T }
  • { end: [T, boolean] }
  • { start: T }
  • { start: T, end: T }
  • { start: T, end: [T, boolean] }
  • { start: [T, boolean] }
  • { start: [T, boolean], end: T }
  • { start: [T, boolean], end: [T, boolean] }

Companion namespace: Range

Definition

export type Range<T> = {
  start: T | [T, boolean];
  end?: T | [T, boolean];
  amount?: undefined;
} | {
  start?: T | [T, boolean];
  end: T | [T, boolean];
  amount?: undefined;
};