-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.d.ts
66 lines (50 loc) · 938 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
export type Range = {
/**
Start of the range.
@default 0
*/
readonly start?: number;
/**
End of the range.
*/
readonly end: number;
/**
Distance between numbers.
Minimum: `1`.
@default 1
*/
readonly step?: number;
/**
Whether or not to include the end value in the range.
@default false
@example
```
import getRange from 'get-range';
console.log(...getRange({start: 3, end: 5, inclusive: true}));
//=> [3, 4, 5]
```
*/
readonly inclusive?: boolean;
};
/**
Lazy number range generator.
@example
```
import getRange from 'get-range';
for (const index of getRange({end: 4})) {
console.log(index);
}
//=> 0
//=> 1
//=> 2
//=> 3
const range = getRange({start: 0, end: 4, step: 2});
range.next().value;
//=> 0
range.next().value;
//=> 2
console.log(...getRange({start: 0, end: -5, step: -1}));
//=> [0, -1, -2, -3, -4]
```
*/
export default function getRange(range: Range): IterableIterator<number>;