Socket
Socket
Sign inDemoInstall

@supercharge/promise-pool

Package Overview
Dependencies
0
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @supercharge/promise-pool

Map-like, concurrent promise processing for Node.js


Version published
Weekly downloads
384K
decreased by-3.1%
Maintainers
3
Install size
18.5 kB
Created
Weekly downloads
 

Changelog

Source

1.2.0 - 2019-10-15

Added

  • static methods for .withConcurrency and .for
    • moves boilerplate from your code to the promise pool package
    • new Pool().for(items) is now Pool.for(items))
    • new Pool().withConcurrency(2) is now Pool.withConcurrency(2))
    • it’s always the details :)

Updated

  • bump dependencies

Readme

Source


Promise Pool

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


Installation · Docs · Usage · API



Build Status Latest Version

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

Keywords

FAQs

Last updated on 15 Oct 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc