Added `async.forEachLimit()` #39

merged 2 commits into from Sep 19, 2011


None yet

3 participants



I've been using async a lot so thanks for writing this! While using async.forEach I find myself constantly running into concurrency limits in node (such as "Too many open file descriptors"). To rectify this problem I've written async.forEachLimit:

  var fs = require('fs'),
      async = require('async');

  var listOfFiles = fs.readdirSync('/path/to/dir/with/many/files');

  // Iterate over the list of files, checking if each one exists, and ensuring 
  // that at most 25 are in-flight at anytime. 
  async.forEachLimit(listOfFiles, 25, function (file, next) {
  }, function (err) {
    console.log('All files in listOfFiles exist');

Let me know your thoughts. I've added tests that I can confirm are passing.





@caolan ping. Thoughts on this?


@caolan ping. Thoughts on this?

@caolan caolan merged commit 37da12f into caolan:master Sep 19, 2011

merged and published on NPM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment