Skip to content

Commit

Permalink
📚 docs(README): Improve code sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed May 3, 2021
1 parent c50d3b2 commit 8060451
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ import {range} from '@iterable-iterator/range';
range( 3 ) ; // 0 1 2
range( 2 , 5 ) ; // 2 3 4
range( 5 , 2 , -1 ) ; // 5 4 3

range(Number.MAX_SAFE_INTEGER).has(1234); // true
range(0, 10, 2).get(3); // 6

// If you only use the iterator feature you can save bytes by calling the
// IterableIterator function directly
import {forwardRangeIterator, backwardRangeIterator} from '@iterable-iterator/range';

for (const x of forwardRangeIterator(0, 10, 1)) ...
for (const x of backwardRangeIterator(10, 0, -1)) ...
// caveat: This requires you to specify all parameters, and choose the correct
// implementation depending on the sign of the `step` parameter.

// For convenience
import {forwardRangeIterator as range} from '@iterable-iterator/range';
```

[![License](https://img.shields.io/github/license/iterable-iterator/range.svg)](https://raw.githubusercontent.com/iterable-iterator/range/main/LICENSE)
Expand Down

0 comments on commit 8060451

Please sign in to comment.