# promise-sequential

> Simple like Promise.all(), but sequentially!

Latest version **1.1.1** (published 2016-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install promise-sequential
pnpm add promise-sequential
yarn add promise-sequential
bun add promise-sequential
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2016-09-20 |
| First published | 2016-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/promise-sequential) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 193 |
| Author | Russian Rebouças |
| Maintainers | russiann |
| Keywords | promise, queue, seq, sequence, sequential |

## Links

- npm: https://www.npmjs.com/package/promise-sequential
- Repository: https://github.com/russiann/promise-sequential
- Homepage: https://github.com/russiann/promise-sequential#readme
- Issues: https://github.com/russiann/promise-sequential/issues
- npm.io page: https://npm.io/package/promise-sequential

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 1.1.1 (latest) — 2016-09-20

## README

# promise-sequential
Simple like Promise.all(), but sequentially!

[![NPM version](https://badge.fury.io/js/promise-sequential.png)](http://badge.fury.io/js/promise-sequential)

[![Npm Downloads](https://nodei.co/npm/promise-sequential.png?downloads=true&stars=true)](https://nodei.co/npm/promise-sequential.png?downloads=true&stars=true)


## Installation

```
npm install --save promise-sequential
```
## Usage

```js
const sequential = require('promise-sequential');

const items = [
  () => new Promise( ... )
  () => new Promise( ... )
  () => new Promise( ... )
];

sequential(items)
.then(res => {
  // ...
})
.catch(err => {
  // ...
})
```

There is only one difference between Promise.all usage and promise-sequential usage: promise-sequential receive an Array of functions that each returns a promise.

Each function brings three params:

| Name              | Description                                                  |
| ----------------- | ------------------------------------------------------------ |
| previousResponse  | The response of previous iteration                           |
| responses         | All responses received at the time                           |
| count             | The current count.                                           |

### More complex usage

```js

const sequential = require('promise-sequential');
const array = [1,2,3,4,5];

sequential(array.map((item) => {
  return function(previousResponse, responses, count) {

    return new Promise(resolve => {
      setTimeout(() => {
        resolve(item)
      }, 1000)
    })

  }
}))
.then(res => {
  // ...
})
.catch(err => {
  // ...
})
```

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