# times-loop

> run a function n times, both sync and async functions are supported

Latest version **3.0.0** (published 2021-02-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install times-loop
pnpm add times-loop
yarn add times-loop
bun add times-loop
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2021-02-08 |
| First published | 2015-09-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Tejesh Mehta |
| Maintainers | tjmehta |
| Keywords | times, loop, n, number, iterator, generator, loops, time |

## Links

- npm: https://www.npmjs.com/package/times-loop
- Repository: https://github.com/tjmehta/times-loop
- Issues: https://github.com/tjmehta/times-loop/issues
- npm.io page: https://npm.io/package/times-loop

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.0.0 (latest) — 2021-02-08
- 2.0.0 — 2016-08-26
- 1.0.0 — 2015-09-15

## README

# times-loop [![Build Status](https://travis-ci.org/tjmehta/times-loop.svg?branch=master)](https://travis-ci.org/tjmehta/times-loop)

run a function n times, returns results as an array

# Usage

#### Supports both ESM and CommonJS

```js
// esm
import times from 'times-loop`
// commonjs
const times = require('times-loop').default
```

#### Simple Example

```js
import times from 'times-loop'

var results = times(6, function (i) {
  console.log(i)
  return i
})
// prints: 0 1 2 3 4 5

console.log(results)
// prints: [0, 1, 2, 3, 4, 5]
```

#### Promise Example: Parallel

runs promise results in parallel

```js
import { timesParallel } from 'times-loop'

const results = await timesParallel(6, function (i) {
  return Promise.resolve(i)
})

console.log(results)
// prints: [0, 1, 2, 3, 4, 5]
```

#### Promise Example: Series

runs promise results in series

```js
import { timeSeries } from 'times-loop'

const results = await timeSeries(6, function (i) {
  return Promise.resolve(i)
})

console.log(results)
// prints: [0, 1, 2, 3, 4, 5]
```

### License

MIT

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