https://github.com/justforuse/promise-limit-all
Promise all, but with max limit
https://github.com/justforuse/promise-limit-all
javascript promise promise-all
Last synced: about 1 month ago
JSON representation
Promise all, but with max limit
- Host: GitHub
- URL: https://github.com/justforuse/promise-limit-all
- Owner: justforuse
- Created: 2021-09-11T13:37:53.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-31T07:36:00.000Z (over 3 years ago)
- Last Synced: 2025-06-03T20:05:04.964Z (about 1 month ago)
- Topics: javascript, promise, promise-all
- Language: JavaScript
- Homepage: https://codesandbox.io/s/promise-limit-all-demo-v80u1
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Promise Limit All
[ ](https://www.npmjs.com/package/promise-limit-all)
This package let you control the number of async function at the same time
[Codesandbox](https://codesandbox.io/s/promise-limit-all-demo-v80u1)
## Demo
```js
const promiseLimitAll = require('promise-limit-all');const promiseFactory = (res, timeout) => {
return () =>
new Promise((resolve) => {
setTimeout(() => {
resolve(res);
}, timeout);
});
};promiseLimitAll(
[
promiseFactory(1, 1000),
promiseFactory(2, 2000),
promiseFactory(3, 2000),
promiseFactory(4, 1000),
promiseFactory(5, 1000),
promiseFactory(6, 500),
promiseFactory(7, 500)
],
3
).then((res) => {
const str = res.join(",");
console.log(str);
});
```Output:
```
1,2,3,4,5,6,7
```