# @hugoalh/range-iterator

> A module to iterate between range.

Latest version **3.0.3** (published 2026-11-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hugoalh/range-iterator
pnpm add @hugoalh/range-iterator
yarn add @hugoalh/range-iterator
bun add @hugoalh/range-iterator
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.3 |
| Published | 2026-11-15 |
| First published | 2023-09-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2 |
| Author | hugoalh |
| Maintainers | hugoalh |
| Keywords | range, iterate, iterator |

## Links

- npm: https://www.npmjs.com/package/@hugoalh/range-iterator
- Repository: https://github.com/hugoalh/range-iterator-es
- Homepage: https://github.com/hugoalh/range-iterator-es#readme
- Issues: https://github.com/hugoalh/range-iterator-es/issues
- npm.io page: https://npm.io/package/@hugoalh/range-iterator

## Recent versions

- 3.0.3 (latest) — 2026-11-15
- 3.0.2 — 2026-10-12
- 3.0.1 — 2026-07-18
- 3.0.0 — 2025-08-09
- 2.1.1 — 2025-05-13
- 2.1.0 — 2024-12-07
- 2.0.5 — 2024-11-14
- 2.0.4 — 2024-10-22
- 2.0.3 — 2024-04-16
- 2.0.2 — 2024-03-29
- 2.0.1 — 2024-01-15
- 2.0.0 — 2024-01-11
- 1.0.0 — 2023-09-27

## README

# Range Iterator (ES)

[**⚖️** MIT](./LICENSE.md)

🔗
[DistBoard @hugoalh](https://hugoalh.github.io/distboard/range_iterator_ecmascript)
● [GitHub](https://github.com/hugoalh/range-iterator-es)
● [JSR](https://jsr.io/@hugoalh/range-iterator)
● [NPM](https://www.npmjs.com/package/@hugoalh/range-iterator)

An ECMAScript module to iterate between range.

## 🎯 Runtime Targets

Any runtime which support ECMAScript should able to use this; These runtimes are officially supported:

- **[Bun](https://bun.sh/)** >= v1.1.0
- **[Deno](https://deno.land/)** >= v2.1.0
- **[NodeJS](https://nodejs.org/)** >= v20.9.0

## 🛡️ Runtime Permissions

This does not request any runtime permission.

## #️⃣ Entrypoints

| **Name** | **Path** | **Description** |
|:--|:--|:--|
| `.` | `./mod.ts` | Default. |

> [!NOTE]
> - Different runtimes have vary support for the entrypoints, visit the runtime documentation for more information.
> - These are not part of the public APIs hence should not be used:
>   - Benchmark/Test file (e.g.: `example.bench.ts`, `example.test.ts`).
>   - Entrypoint name or path include any underscore prefix (e.g.: `_example.ts`, `foo/_example.ts`).
>   - Identifier/Namespace/Symbol include any underscore prefix (e.g.: `_example`, `Foo._example`).

## 🧩 APIs

- ```ts
  function rangeIterator(start: bigint, end: bigint, options?: RangeIteratorOptions<bigint>): Generator<bigint>;
  function rangeIterator(start: bigint, end: bigint, step: bigint): Generator<bigint>;
  function rangeIterator(start: number, end: number, options?: RangeIteratorOptions<number>): Generator<number>;
  function rangeIterator(start: number, end: number, step: number): Generator<number>;
  function rangeIterator(start: string, end: string, options?: RangeIteratorOptions<string>): Generator<string>;
  function rangeIterator(start: string, end: string, step: number): Generator<string>;
  ```
- ```ts
  interface RangeIteratorOptions<T extends bigint | number | string> {
    excludeEnd?: boolean;
    excludes?: readonly T[] | Set<T>;
    excludeStart?: boolean;
    step?: T extends string ? number : T;
  }
  ```

> [!NOTE]
> - For the full or prettier documentation, can visit via:
>   - [Deno CLI `deno doc`](https://docs.deno.com/runtime/reference/cli/doc)
>   - [JSR](https://jsr.io/@hugoalh/range-iterator)

## ✍️ Examples

- ```ts
  Array.from(rangeIterator(1, 9));
  //=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
  ```
- ```ts
  Array.from(rangeIterator(1n, 9n, { excludeEnd: true }));
  //=> [1n, 2n, 3n, 4n, 5n, 6n, 7n, 8n]
  ```
- ```ts
  Array.from(rangeIterator(1, 9, { step: 0.5 }));
  //=> [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9]
  ```
- ```ts
  Array.from(rangeIterator("a", "z"));
  //=> ["a", "b", "c", ... +20 ..., "x", "y", "z"]
  ```
- ```ts
  Array.from(rangeIterator(9, 1));
  //=> [9, 8, 7, 6, 5, 4, 3, 2, 1]
  ```
- ```ts
  Array.from(rangeIterator(9n, 1n, { excludeEnd: true }));
  //=> [9n, 8n, 7n, 6n, 5n, 4n, 3n, 2n]
  ```
- ```ts
  Array.from(rangeIterator(9, 1, { step: 0.5 }));
  //=> [9, 8.5, 8, 7.5, 7, 6.5, 6, 5.5, 5, 4.5, 4, 3.5, 3, 2.5, 2, 1.5, 1]
  ```
- ```ts
  Array.from(rangeIterator("z", "a"));
  //=> ["z", "y", "x", ... +20 ..., "c", "b", "a"]
  ```

---
_Source: https://npm.io/package/@hugoalh/range-iterator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
