Skip to content

Commit

Permalink
update inclusive example
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell committed Jan 2, 2024
1 parent 1397a5d commit ce9b670
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export type Range = {
Whether or not to include the end value in the range.
@default false
@example
```
console.log(...getRange({start: 3, end: 5, inclusive: true}));
//=> [3, 4, 5]
```
*/
readonly inclusive?: boolean;
};
Expand Down Expand Up @@ -51,8 +56,8 @@ range.next().value;
range.next().value;
//=> 2
console.log(...getRange({start: 0, end: -5, step: -1, inclusive: true}));
//=> [0, -1, -2, -3, -4, -5]
console.log(...getRange({start: 0, end: -5, step: -1}));
//=> [0, -1, -2, -3, -4]
```
*/
export default function getRange(range: Range): IterableIterator<number>;
9 changes: 7 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ range.next().value;
range.next().value;
//=> 2

console.log(...getRange({start: 0, end: -5, step: -1, inclusive: true}));
//=> [0, -1, -2, -3, -4, -5]
console.log(...getRange({start: 0, end: -5, step: -1}));
//=> [0, -1, -2, -3, -4]
```

It can replace normal for-loops in many cases:
Expand Down Expand Up @@ -84,3 +84,8 @@ Type: `boolean`\
Default: `false`

Whether or not to include the end value in the range.

```js
console.log(...getRange({start: 3, end: 5, inclusive: true}));
//=> [3, 4, 5]
```

0 comments on commit ce9b670

Please sign in to comment.