# repeatjs

> A JS library to remove boilerplate from for-loops.

Latest version **1.0.3** (published 2022-11-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install repeatjs
pnpm add repeatjs
yarn add repeatjs
bun add repeatjs
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-11-16 |
| First published | 2022-11-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Anoch Jeyakanthan |
| Maintainers | saddev |
| Keywords | repeat, loop, boilerplate, fastloop, forloop, whileloop, repeatjs, repeatcode, ease, anoch, anoch jeyakanthan |

## Links

- npm: https://www.npmjs.com/package/repeatjs
- Repository: https://github.com/ItsAnoch/repeatjs.git#main
- Homepage: https://github.com/ItsAnoch/repeatjs/blob/main/README.md
- Issues: https://github.com/ItsAnoch/repeatjs/issues
- npm.io page: https://npm.io/package/repeatjs

## Recent versions

- 1.0.3 (latest) — 2022-11-16
- 1.0.2 — 2022-11-16
- 1.0.1 — 2022-11-16
- 1.0.0 — 2022-11-16

## README

# RepeatJS
#### JS Library to remove boiler-plate from loops.
#### Exact same speed as a normal for-loop.
---

## Installation
```
npm install repeatjs
```
---
## Importing
```
import repeat from "repeatjs/index.js";
```
---

## Syntax:
```js
repeat((index, end) => { // Index and end can be renamed to anything.
    // code here
}, iterations, step, start)
```

<br>

## Example Code
> Output numbers from 0 to 10
```js
repeat((index) => {
    console.log(index)
}, 10)
```

<br>

> Output numbers from 5 to 20
```js
repeat((index) => {
    console.log(index)
}, 20, 1, 5) // 20 is the iterations, 1 is the step, and 5 is the starting.
```

<br>

> Output even numbers from 10 to 20
```js
repeat((index) => {
    console.log(index)
}, 20, 2, 10) // 20 is the iterations, 2 is the step, and 5 is the starting.
```

<br>

> If the index is equal to a random number then break the loop.
```js
const number = Math.floor(Math.random() * 20)

repeat((index, end) => {
    if (index == number) {
        end() // end() is equivalent to `break`; however end() can be used in functions unlike break; 
    }
    console.log(index)
}, 20)
```

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