Skip to content
Map-like, concurrent promise processing
JavaScript
Branch: master
Clone or download
Latest commit 9516fd1 Oct 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples add static methods: .for and .withConcurrency Oct 15, 2019
src add static methods: .for and .withConcurrency Oct 15, 2019
test add static methods: .for and .withConcurrency Oct 15, 2019
.eslintrc.json initial Jul 9, 2019
.gitignore update .gitignore Jul 9, 2019
.travis.yml add .travis.yml Jul 12, 2019
CHANGELOG.md update changelog Oct 15, 2019
LICENSE Initial commit Jul 9, 2019
README.md Update README.md Oct 15, 2019
index.js module.exports.default Aug 14, 2019
package.json 1.2.0 Oct 15, 2019

README.md



Promise Pool

Map-like, concurrent promise processing for Node.js.


Installation · Docs · Usage



Build Status Latest Version Monthly downloads

Follow @marcuspoehls and @superchargejs for updates!


Installation

npm i @supercharge/promise-pool

Docs

Find all the details and available methods in the extensive Supercharge docs.

Usage

Using the promise pool is pretty straightforward. The pacakge exposes a class and you can create a promise pool instance using the fluent interface.

Here’s an example using the default concurrency of 10:

const PromisePool = require('@supercharge/promise-pool')

const users = [
  { name: 'Marcus' },
  { name: 'Norman' },
  { name: 'Christian' }
]

const { results, errors } = await PromisePool
  .for(users)
  .process(async data => {
    const user = await User.createIfNotExisting(data)

    return user
  })

You can surely refine the concurrency to your needs using the .withConcurrency method:

await PromisePool
  .for(users)
  .withConcurrency(2)
  .process(async data => {
    //
  })

Contributing

  1. Create a fork
  2. Create your feature branch: git checkout -b my-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request 🚀

License

MIT © Supercharge


superchargejs.com  ·  GitHub @superchargejs  ·  Twitter @superchargejs

You can’t perform that action at this time.