https://github.com/rodrigogs/promise-pool
This promise pool keeps looping `Promise.all`'s promises until the last generator item is submitted to the processor.
https://github.com/rodrigogs/promise-pool
async generator javascript nodejs poller pool promise promises
Last synced: 6 months ago
JSON representation
This promise pool keeps looping `Promise.all`'s promises until the last generator item is submitted to the processor.
- Host: GitHub
- URL: https://github.com/rodrigogs/promise-pool
- Owner: rodrigogs
- License: bsd-3-clause
- Created: 2020-01-31T23:39:36.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T14:20:44.000Z (over 3 years ago)
- Last Synced: 2025-10-29T12:15:50.788Z (8 months ago)
- Topics: async, generator, javascript, nodejs, poller, pool, promise, promises
- Language: JavaScript
- Size: 1010 KB
- Stars: 15
- Watchers: 1
- Forks: 1
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# promise-pool
This promise pool keeps looping `Promise.all`'s promises until the last generator item is submitted to the processor.
## Install
`$ npm install @rodrigogs/promise-pool`
## Usage
```javascript
const promisePool = require('@rodrigogs/promise-pool');
function* generatorFunction(start, end) { // Could be an async generator
for (let i = start; i <= end; i += 1) {
yield i;
}
}
function processor(generatorValue) { // Could be an async function
console.log(generatorValue);
}
(async () => {
await promisePool({
generator: generatorFunction(100, 1000),
processor,
concurrency: 10,
});
})();
```
## License
[BSD-3-Clause](https://github.com/rodrigogs/promise-pool/blob/master/LICENSE) © Rodrigo Gomes da Silva