Skip to main content

namespace Range

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 type: Range<T>

Functions

getNormalizedRange

Simplifies a given range Range input for easier processing, by returning optional start and end ranges including whether they are inclusive or exclusive

Definition

function getNormalizedRange<T>(range: Range<T>): {
    start?: [T, boolean] | undefined;
    end?: [T, boolean] | undefined;
  };

Type parameters
NameDescription
T

Parameters

NameTypeDescription
rangeRange<T>the Range to use