# repeat

> create repeating task chains

Latest version **2.0.4** (published 2021-06-28) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2021-06-28 |
| First published | 2012-09-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 117 |
| Maintainers | master-chief |
| Keywords | task, repeating, chain, tasks, scheduler, loop, repeat |

## Links

- npm: https://www.npmjs.com/package/repeat
- Repository: https://github.com/117/repeat
- Homepage: https://github.com/117/repeat#readme
- Issues: https://github.com/117/repeat/issues
- npm.io page: https://npm.io/package/repeat

## Recent versions

- 2.0.4 (latest) — 2021-06-28
- 2.0.3 — 2020-11-11
- 2.0.2 — 2020-11-11
- 2.0.1 — 2020-11-11
- 2.0.0 — 2020-11-11
- 1.2.0 — 2019-07-09
- 1.1.4 — 2019-04-06
- 1.1.3 — 2019-04-06
- 1.1.2 — 2019-03-19
- 1.1.1 — 2019-03-16
- 1.1.0 — 2019-03-15
- 1.0.3 — 2019-03-13
- 1.0.2 — 2019-03-13
- 1.0.1 — 2019-03-13
- 1.0.0 — 2019-03-13
- … 6 more at https://npm.io/package/repeat/versions

## README

# repeat

![version](https://img.shields.io/github/package-json/v/117/repeat?color=196DFF&style=flat-square)
![language](https://img.shields.io/github/languages/code-size/117/repeat?color=F1A42E&style=flat-square)
![maintenance](https://img.shields.io/github/workflow/status/117/repeat/test?style=flat-square)
![prettier](https://img.shields.io/static/v1?label=code%20style&message=prettier&color=ff51bc&style=flat-square)

create repeating task chains

## Contents

- [Features](#features)
- [Install](#install)
- [Chain](#chain)
- [Contributing](#contributing)

## Features

- [x] Chain any number of tasks and repeat them once or forever.
- [x] Optional synchronous and asynchronous API.

## Install

From NPM:

```cmd
> npm i repeat
```

## Chain

### Creating a new chain

The following chain will execute all tasks every second. A task is any callable
function.

```javascript
// ES6
import { Chain } from 'repeat'

// ES5
// let { Chain } = require('repeat')

let chain = new Chain()

chain
  .add(
    // task A
    () => console.log('how are you?'),
    // task B
    () => console.log('good')
    // you can add task C, D, E, F ...
  )
  .every(1000)
```

### Examples

The following methods are available on the chain.

- [add](#add)
- [once](#once)
- [every](#every)
- [forever](#forever)
- [cancel](#cancel)

#### add

```typescript
// add any number of tasks to the chain
chain.add(
  () => console.log('cat'),
  () => console.log('dog'),
  () => console.log('fish')
)
```

#### once

```typescript
// execute the tasks once
chain.once()
```

#### every

```typescript
// execute the tasks asynchronously every second
chain.every(1000)
```

#### forever

```typescript
// execute the tasks as fast as possible
chain.forever()
```

#### cancel

```typescript
// halt further execution of tasks
chain.cancel()
```

## Contributing

Pull requests are encouraged. 😁

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