|
há 4 anos atrás | |
---|---|---|
.. | ||
index.js | há 7 anos atrás | |
license | há 7 anos atrás | |
package.json | há 4 anos atrás | |
readme.md | há 7 anos atrás |
Run multiple promise-returning & async functions with limited concurrency
$ npm install --save p-limit
const pLimit = require('p-limit');
const limit = pLimit(1);
const input = [
limit(() => fetchSomething('foo')),
limit(() => fetchSomething('bar')),
limit(() => doSomething())
];
// only one promise is run at once
Promise.all(input).then(result => {
console.log(result);
});
Returns a limit
function.
Type: number
Minimum: 1
Concurrency limit.
Returns the promise returned by calling fn
.
Type: Function
Promise-returning/async function.
MIT © Sindre Sorhus