Skip to main content

type IndexRange

A flexible range specification for numeric indices. 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 or exclusive. An IndexRange can have one of the following forms:

  • { amount: number }
  • { start: number }
  • { start: number, amount: number }
  • { start: number, end: number }
  • { start: number, end: [number, boolean] }
  • { start: [number, boolean] }
  • { start: [number, boolean], amount: number }
  • { start: [number, boolean], end: number }
  • { start: [number, boolean], end: [number, boolean] }
  • { end: number }
  • { end: [number, boolean] }

Companion namespace: IndexRange

Definition

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