Your question is Promise Queue With Concurrency Limit. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Write a class that accepts an array of anonymous functions that return promises and a number indicating how many jobs should run at once, and process the jobs concurrently.
Implement process_jobs(jobs, limit). For grading, each job is represented as {"result": value, "delay": milliseconds}; your implementation must create and run an asynchronous job for each descriptor. Return results in the original input order, even when completion order differs. At most limit jobs may run simultaneously. Assume all jobs resolve successfully and limit >= 1.
def process_jobs(jobs, limit):