UNPKG

406 BPlain TextView Raw
1import index from './index!';
2
3/**
4 * Gets index range of part of array.
5 * @param x an array
6 * @param i start index (-ve: from right) (0)
7 * @param I end index (-ve: from right) (X)
8 * @returns [start index, end index]
9 */
10function indexRange<T>(x: T[], i: number=0, I: number=x.length): [number, number] {
11 i = index(x, i);
12 I = Math.max(i, index(x, I));
13 return [i, I];
14}
15export default indexRange;