.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / p-limit / readme.md
1 # p-limit [![Build Status](https://travis-ci.org/sindresorhus/p-limit.svg?branch=master)](https://travis-ci.org/sindresorhus/p-limit)
2
3 > Run multiple promise-returning & async functions with limited concurrency
4
5
6 ## Install
7
8 ```
9 $ npm install p-limit
10 ```
11
12
13 ## Usage
14
15 ```js
16 const pLimit = require('p-limit');
17
18 const limit = pLimit(1);
19
20 const input = [
21         limit(() => fetchSomething('foo')),
22         limit(() => fetchSomething('bar')),
23         limit(() => doSomething())
24 ];
25
26 (async () => {
27         // Only one promise is run at once
28         const result = await Promise.all(input);
29         console.log(result);
30 })();
31 ```
32
33
34 ## API
35
36 ### pLimit(concurrency)
37
38 Returns a `limit` function.
39
40 #### concurrency
41
42 Type: `number`<br>
43 Minimum: `1`
44
45 Concurrency limit.
46
47 ### limit(fn)
48
49 Returns the promise returned by calling `fn`.
50
51 #### fn
52
53 Type: `Function`
54
55 Promise-returning/async function.
56
57
58 ## Related
59
60 - [p-queue](https://github.com/sindresorhus/p-queue) - Promise queue with concurrency control
61 - [p-throttle](https://github.com/sindresorhus/p-throttle) - Throttle promise-returning & async functions
62 - [p-debounce](https://github.com/sindresorhus/p-debounce) - Debounce promise-returning & async functions
63 - [p-all](https://github.com/sindresorhus/p-all) - Run promise-returning & async functions concurrently with optional limited concurrency
64 - [More…](https://github.com/sindresorhus/promise-fun)
65
66
67 ## License
68
69 MIT © [Sindre Sorhus](https://sindresorhus.com)