# p-series

> Run promise-returning & async functions in series

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

## Install

```sh
npm install p-series
pnpm add p-series
yarn add p-series
bun add p-series
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2021-08-12 |
| First published | 2016-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/p-series) |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 72 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | promise, series, serial, sequence, sequential, ordered, task, tasks, array, collection, iterable, iterator, async, await, promises, bluebird |

## Links

- npm: https://www.npmjs.com/package/p-series
- Repository: https://github.com/sindresorhus/p-series
- Homepage: https://github.com/sindresorhus/p-series#readme
- Issues: https://github.com/sindresorhus/p-series/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/p-series

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2021-08-12
- 2.1.0 — 2019-04-05
- 2.0.0 — 2019-03-12
- 1.1.0 — 2018-03-06
- 1.0.0 — 2016-11-22

## README

# p-series

> Run promise-returning & async functions in series

*Note:* You can just use `await` in a for-loop to get the same behavior. This package was useful before async/await existed.

If you're doing the same work in each function, use [`p-each-series`](https://github.com/sindresorhus/p-each-series) instead.

See [`p-all`](https://github.com/sindresorhus/p-all) for a concurrent counterpart.

## Install

```
$ npm install p-series
```

## Usage

```js
import pSeries from 'p-series';
import got from 'got';

const tasks = [
	() => got('https://sindresorhus.com'),
	() => checkSomething(),
	() => doSomethingElse()
];

console.log(await pSeries(tasks));
```

## API

### pSeries(tasks)

Returns a `Promise` that is fulfilled when all promises returned from calling the functions in `tasks` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values.

#### tasks

Type: `Iterable<Function>`

Functions are expected to return a value. If a Promise is returned, it's awaited before continuing with the next task.

## Related

- [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
- [p-waterfall](https://github.com/sindresorhus/p-waterfall) - Run promise-returning & async functions in series, each passing its result to the next
- [p-each-series](https://github.com/sindresorhus/p-each-series) - Iterate over promises serially
- [More…](https://github.com/sindresorhus/promise-fun)

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