finish

Provides a single callback for multiple asynchronous calls

Finish.js

======

Finish is a node utility module that provides a simple straight-forward way to catch the completion of multiple asynchronous tasks.

You can install using Node Package Manager (npm):

npm install finish
var Finish = require("finish");
var finish = new Finish();
finish.async(function(spawn) { // Open an asynchronous region 
  // Now you can make any asynchronous calls 
  // Just wrap each asynchronous call with function 'spawn' 
  ['file1', 'file2', 'file3'].forEach(function(file) {
    spawn(function(done) { 
      path.exists(function(errresult) {
        // Your async function should call done in its callback 
        // 'result' passed into 'done' will be collected in the final callback 
        done(err, result);
      });
    });
  });
}, function(errresults) {
  // This callback is fired after all asynchronous calls finish 
  // results now equals an array of results received from by each 'done' 
});

There are more detailed examples in the examples directory.

Finish can be use within recursive function calls. Just be sure to create a new finish instance in every recursive call.