The Async library has functions like eachLimit which can be used to efficiently spread a big batch of jobs over multiple CPU cores, like this:
var numCPUs = require('os').cpus().length;
var exec = require('child_process').exec;
async.eachLimit(someArray, numCPUs, function (value, done) {
exec('something --input' + value, done);
}, finalCallback);
This avoids overloading the system with too many commands at once, but still exploits multiple CPUs.
I want to do the same thing but with Promises.
In the Bluebird API, I can't see any obvious way to do this kind of batching in such a concise, expressive way as with Async.
Is there a good pattern for doing this with Bluebird (or with Promises generally)? Or any other utility library I could use for this?