This is a simple executor queue, which supports dynamic limited concurrency for all queued Functions/Promises. I find myself requiring small utilities like this frequently, so it's getting dumped here for future reference.
The concurrency limit can be adjusted in realtime, even while pending tasks are queued,
and the queue will execute more (or fewer) tasks in order to reach the new target.
The results or errors from the queued tasks will be safely managed,
and directly returned or raised back through the Promise returned by queue.add.
The queue itself is relatively lightweight, requiring no long-running timers or loops, and has been tested extensively for memory leaks and recursion limits in Bun and Node.