UNPKG

1.21 kBMarkdownView Raw
1# p-pipe [![Build Status](https://travis-ci.org/sindresorhus/p-pipe.svg?branch=master)](https://travis-ci.org/sindresorhus/p-pipe)
2
3> Compose promise-returning & async functions into a reusable pipeline
4
5
6## Install
7
8```
9$ npm install p-pipe
10```
11
12
13## Usage
14
15```js
16const pPipe = require('p-pipe');
17
18const addUnicorn = async string => `${string} Unicorn`;
19const addRainbow = async string => `${string} Rainbow`;
20
21const pipeline = pPipe(addUnicorn, addRainbow);
22
23(async () => {
24 console.log(await pipeline('❤️'));
25 //=> '❤️ Unicorn Rainbow'
26})();
27```
28
29
30## API
31
32### pPipe(input…)
33
34The `input` functions are applied from left to right.
35
36#### input
37
38Type: `Function`
39
40Expected to return a `Promise` or any value.
41
42
43## Related
44
45- [p-each-series](https://github.com/sindresorhus/p-each-series) - Iterate over promises serially
46- [p-series](https://github.com/sindresorhus/p-series) - Run promise-returning & async functions in series
47- [p-waterfall](https://github.com/sindresorhus/p-waterfall) - Run promise-returning & async functions in series, each passing its result to the next
48- [More…](https://github.com/sindresorhus/promise-fun)
49
50
51## License
52
53MIT © [Sindre Sorhus](https://sindresorhus.com)