Henri Lapierre Henri Lapierre - 3 months ago 9
Node.js Question

NodeJS batching async.parallel

I have

async.parallel(tasksGetContentFromGitHub, function(err, res) {
// all request over, do something
}


the problem is that I might have a large number of tasks, and each of them is sending a request to GitHub.

Since I am a nice citizen, I don't want to send 1000+ queries at once at GitHub, therefore I would like to batch those requests 10 at the time, and then execute my inner code.

Is there an easy way to do that?

Answer

You can try async.parallelLimit:

async.parallelLimit(tasksGetContentFromGitHub, 10, function(err, res) {
    // all request over, do something
}

Hope that it can help!

Comments