Map-like, concurrent promise processing for Node.js.
Installation · Docs · Usage
Follow @marcuspoehls and @superchargejs for updates!
npm i @supercharge/promise-pool
Find all the details and available methods in the extensive Supercharge docs.
Using the promise pool is pretty straightforward. The package exposes a class and you can create a promise pool instance using the fluent interface.
Here’s an example using a concurrency of 2:
const PromisePool = require('@supercharge/promise-pool')
const users = [
{ name: 'Marcus' },
{ name: 'Norman' },
{ name: 'Christian' }
]
const { results, errors } = await PromisePool
.withConcurrency(2)
.for(users)
.process(async data => {
const user = await User.createIfNotExisting(data)
return user
})
The promise pool uses a default concurrency of 10:
await PromisePool
.for(users)
.process(async data => {
// processes 10 items in parallel by default
})
- Create a fork
- Create your feature branch:
git checkout -b my-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request 🚀
MIT © Supercharge
superchargejs.com · GitHub @superchargejs · Twitter @superchargejs