# promises-pipeline

> Sequentially run promise-returning functions, passing the result of each one to its next

Latest version **1.0.4** (published 2022-02-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install promises-pipeline
pnpm add promises-pipeline
yarn add promises-pipeline
bun add promises-pipeline
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2022-02-01 |
| First published | 2016-11-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 1 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alexis Menest |
| Maintainers | alexismenest |
| Keywords | promise, promises, promises-a, promises-aplus, pipeline, sequence, sequential, chain, waterfall, series, serial, async, reduce, task, tasks, iterable, iterator, bluebird |

## Links

- npm: https://www.npmjs.com/package/promises-pipeline
- Repository: https://github.com/alexismenest/promises-pipeline
- Homepage: https://github.com/alexismenest/promises-pipeline#readme
- Issues: https://github.com/alexismenest/promises-pipeline/issues
- npm.io page: https://npm.io/package/promises-pipeline

## Dependencies (1)

- [bluebird](https://npm.io/package/bluebird.md) ^3.7.2

## 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

- 1.0.4 (latest) — 2022-02-01
- 1.0.3 — 2017-11-19
- 1.0.2 — 2017-09-23
- 1.0.1 — 2017-09-17
- 1.0.0 — 2016-11-25

## README

# promises-pipeline

Sequentially run promise-returning functions, passing the result of each one to its next

[![Build status](https://travis-ci.org/alexismenest/promises-pipeline.svg?branch=master)](https://travis-ci.org/alexismenest/promises-pipeline)

[![Coverage Status](https://coveralls.io/repos/github/alexismenest/promises-pipeline/badge.svg?branch=master)](https://coveralls.io/github/alexismenest/promises-pipeline?branch=master)


## Installation

```sh
npm install promises-pipeline --save
```

## API

### pipeline(tasks[, initialValue])

* `tasks` `{Iterable<Function>}` An iterable of promise-returning functions
* `initialValue` `{any}` An optional initial value of any type

`pipeline()` returns a promise that resolves when all of the promises in the given functions have resolved or, if any of the promises rejects, rejects immediately with the reason of the first promise that rejected, discarding all the other promises whether or not they have resolved. 

## Usage

```js
const pipeline = require('promises-pipeline');

const errorTask = () => Promise.reject(new Error('Failed generating "Hello, World!"'));
const helloTask = () => Promise.resolve('Hello,');
const hiTask    = input => Promise.resolve(`Hi${input}`);
const worldTask = input => Promise.resolve(`${input} World!`);

const helloWorldTasks = new Map();
helloWorldTasks.set('helloTask', helloTask);
helloWorldTasks.set('worldTask', worldTask);

const hiWorldTasks = new Set();
hiWorldTasks.add(hiTask);
hiWorldTasks.add(worldTask);

const failureTasks = [helloTask, errorTask, worldTask];

pipeline(helloWorldTasks.values())
  .then(output => console.log(output))// => 'Hello, World!'
  .catch(err => console.error(err.message));

pipeline(hiWorldTasks, ',')
  .then(output => console.log(output))// => 'Hi, World!'
  .catch(err => console.error(err.message));

pipeline(failureTasks)
  .then(output => console.log(output))
  .catch(err => console.error(err.message));// => 'Failed generating "Hello, World!"'
```

## Tests

```sh
npm test
```

## License

This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.

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