co-parallel
Execute thunks in parallel with concurrency support
A JavaScript utility that runs multiple async tasks at the same time with a concurrency limit, returning results in the original order. Built on the older co/generator async pattern.
co-parallel is a JavaScript utility that runs multiple async tasks simultaneously while making sure the results come back in the same order you started them. It also lets you cap how many tasks run at the same time, so you don't overwhelm your system or get rate-limited by external services.
The library addresses a specific pain point: you might fire off dozens of HTTP requests at once and hit a server's rate limit or max out your own resources. Instead of sending all requests simultaneously, co-parallel processes them in controlled batches. You give it a list of tasks and a concurrency number (defaulting to 5), and it runs that many at a time until all are done. Once everything finishes, you get back an array of results positioned to match your original task list—so even if task 3 completes before task 1, the results are ordered correctly.
This would be useful for developers building things like web scrapers, API aggregators, or batch-processing scripts. For example, if you need to check the HTTP status of 50 URLs, you could use this to fetch them 5 at a time rather than all at once. The controlled concurrency keeps you from getting blocked or crashing your app, and the ordering guarantee means you can reliably match each result back to its source.
The project is built around generator functions and the co library, which was a popular pattern for managing async code in Node.js before async/await became native. It works with "thunks"—a specific kind of function representation. The README doesn't go into much detail beyond the basic API and a single example, so you'd need some familiarity with this older async style to use it effectively.
Where it fits
- Build a web scraper that fetches pages in controlled batches to avoid rate limits.
- Check HTTP status of many URLs five at a time instead of all at once.
- Aggregate data from multiple APIs without overwhelming your system resources.