Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
concurrency-master
Advanced tools
The Concurrency Master is a lightweight promise-based task scheduler. Initialize it with a concurrency value, then call its add
method on functions that return Promises. The ConcurrencyMaster will execute all the given promise-returning functions. In doing so, it will make sure that no more than its given concurrency are running in parallel.
The wait()
method returns a Promise that resolves when all of the ConcurrencyMaster's add
ed Promises have resolved.
var ConcurrencyMaster = require('concurrency-master');
function waitOneSecondAndLog() {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log('Hey!');
resolve();
}, 1000);
});
}
var concurrencyMaster = new ConcurrencyMaster(2);
concurrencyMaster.add(waitOneSecondAndLog);
concurrencyMaster.add(waitOneSecondAndLog);
concurrencyMaster.add(waitOneSecondAndLog);
concurrencyMaster.wait().then(() => {
console.log('all done!');
});
The ConcurrencyMaster in this example has a concurrency of 2, so after one second, you'll see two Hey!
messages. After another second, you'll see the third Hey!
message, then all done!
. Sweet!
FAQs
a promise concurrency manager
The npm package concurrency-master receives a total of 2 weekly downloads. As such, concurrency-master popularity was classified as not popular.
We found that concurrency-master demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.