Concurrency Controller
Invokes functions concurrently with a given degree of concurrency.
It puts given functions in a queue and keeps a specific number of them (concurrencyLimit) running simultaneously. By the time a function's execution gets done (resolves/rejects), another function from the queue is invoked.
To install:
npm install concurrency-controller
Usage:
let ConcurrencyController = ;let concurrencyLimit = 2;let myConcurrentList = concurrencyLimit; // Put several functions and corresponding arguments into myConcurrentListfor let i = 0; i < 1000; i++ myConcurrentList ; // You can change concurrency limit during executionmyConcurrentList; // You can get result via callbackmyConcurrentList; // You can get result of all function calls when all of them executed// By callback:myConcurrentList;// Or by promise:myConcurrentList; { return { // your code };}
License
MIT License
Copyright (c) 2019 Majid Yaghouti
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.