# for-range

> Simplified syntax for a for loop.

Latest version **1.0.0** (published 2019-12-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install for-range
pnpm add for-range
yarn add for-range
bun add for-range
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-12-06 |
| First published | 2019-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Richie Bendall |
| Maintainers | richienb |
| Keywords | for, loop, interation, callback, simplified, wrapper |

## Links

- npm: https://www.npmjs.com/package/for-range
- Repository: https://github.com/Richienb/for-range
- npm.io page: https://npm.io/package/for-range

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-12-06

## README

# For Range [![Travis CI Build Status](https://img.shields.io/travis/com/Richienb/for-range/master.svg?style=for-the-badge)](https://travis-ci.com/Richienb/for-range)

Simplified syntax for a for loop.

[![NPM Badge](https://nodei.co/npm/for-range.png)](https://npmjs.com/package/for-range)

## Install

```sh
npm install for-range
```

## Usage

```js
const forRange = require("for-range");

forRange({ min: 2, max: 10, step: 2 }, (i) => {
    if (i === 4) return; // Skip for 4
    if (i === 8) return false; // Stop for loop at 8
    console.log(i);
});

// Native JS equaivent
for (let i = 2; i <= 10; i += 2) {
    if (i === 4) continue;
    if (i === 8) break;
    console.log(i);
}
```

## API

### forRange(options, callback)

#### options

Type: `object`

##### min

Type: `number`\
Default: `0`

The number to start the for loop at.

##### max

Type: `number`

The number to end the for loop at.

##### step

Type: `number`\
Default: `1`

The amount to add to the number each iteration

#### callback

Type: `function`

The callback to trigger for each iteration.

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