namespace 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 type: IndexRange
Functions
getIndexRangeIndices
Returns, given the range
IndexRange
, a normalized tuple containing the start index, and optionally an end index.
getIndexRangeIndices
range
IndexRange
, a normalized tuple containing the start index, and optionally an end index.Definition
function getIndexRangeIndices(range:
IndexRange
): [number, number
|
undefined];
Parameters
Name | Type | Description |
---|---|---|
range | IndexRange | the IndexRange to use |
getIndicesFor
Returns, given the range
IndexRange
, and a target maximum length
, the actual index range. This can be one of three options: - 'empty': there are no elements within the range - 'all': all elements are within the range - [start: number, end: number]: an inclusive range of element indices within the given range
getIndicesFor
range
IndexRange
, and a target maximum length
, the actual index range. This can be one of three options: - 'empty': there are no elements within the range - 'all': all elements are within the range - [start: number, end: number]: an inclusive range of element indices within the given rangeDefinition
function getIndicesFor(range:
IndexRange
, length: number): [number, number]
|
'empty'
|
'all';
Parameters
Name | Type | Description |
---|---|---|
range | IndexRange | the IndexRange to use |
length | number | the target maximum length |