There is a nodejs module that lets you limit the number of concurrent promises:
https://github.com/sindresorhus/p-queue
Does this make use of multiple threads?
Example from the official page:
const {default: PQueue} = require('p-queue');
const got = require('got');
const queue = new PQueue({concurrency: os.cpus().length});
(async () => {
await queue.add(() => got('sindresorhus.com'));
console.log('Done: sindresorhus.com');
})();
(async () => {
await queue.add(() => got('ava.li'));
console.log('Done: ava.li');
})();
(async () => {
const task = await getUnicornTask();
await queue.add(task);
console.log('Done: Unicorn task');
})();
Will it run each of the async functions above in different cpu threads?