https://github.com/iterable-iterator/range
:mountain: A range function for JavaScript
https://github.com/iterable-iterator/range
Last synced: about 1 year ago
JSON representation
:mountain: A range function for JavaScript
- Host: GitHub
- URL: https://github.com/iterable-iterator/range
- Owner: iterable-iterator
- License: agpl-3.0
- Created: 2021-04-27T13:15:06.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-03-12T16:24:59.000Z (about 1 year ago)
- Last Synced: 2025-04-07T17:40:23.513Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://iterable-iterator.github.io/range
- Size: 1.91 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
:mountain: [@iterable-iterator/range](https://iterable-iterator.github.io/range)
==
A range function for JavaScript.
See [docs](https://iterable-iterator.github.io/range/index.html).
> :warning: Depending on your environment, the code may require
> `regeneratorRuntime` to be defined, for instance by importing
> [regenerator-runtime/runtime](https://www.npmjs.com/package/regenerator-runtime).
```js
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, rangeIterator will return the correct kind of
// IterableIterator without constructing a Range object. It has the same signature
// as the range function.
import {rangeIterator as range} from '@iterable-iterator/range';
```
[](https://raw.githubusercontent.com/iterable-iterator/range/main/LICENSE)
[](https://www.npmjs.org/package/@iterable-iterator/range)
[](https://github.com/iterable-iterator/range/actions/workflows/ci.yml?query=branch:main)
[](https://github.com/iterable-iterator/range/network/dependencies)
[](https://github.com/iterable-iterator/range/issues)
[](https://www.npmjs.org/package/@iterable-iterator/range)
[](https://codeclimate.com/github/iterable-iterator/range/issues)
[](https://codeclimate.com/github/iterable-iterator/range/trends/churn)
[](https://codecov.io/gh/iterable-iterator/range)
[](https://codeclimate.com/github/iterable-iterator/range/trends/technical_debt)
[](https://iterable-iterator.github.io/range/source.html)
[](https://bundlephobia.com/result?p=@iterable-iterator/range)