/**
 * Module dependencies
 */

var assert = require('assert');

/**
 * Expose 'foyer'
 */

module.exports = foyer;

/**
 * Foyer
 *
 * @param {Function[]} tasks
 * @param {Function} cb
 * @api public
 */

function foyer(tasks, cb) {
  assert('[object Array]' == Object.prototype.toString.call(tasks), 'Tasks must be an array of functions');
  cb = cb || function(){};
  var done = false;
  var results = [];
  var errors = [];
  var index = 0;

  function next() {
    var i = index++;
    var fn = tasks[i];
    if (!fn) return;
    
    try{
      fn(callback)
    } catch(err) {
      callback(err)
    }

    function callback(err, res) {
      if (done) return;
      if (err) return done = true, cb(err);

      results[i] = res;
      errors[i] = err;
      if(index == tasks.length) cb(errors, results);
    }
  }

  for (var i = 0; i < tasks.length; i++) {
    next();
  }

  return this;
}
@@ -227,16 +227,77 @@
 , cb) %7B%0A
+  if (!(this instanceof foyer)) return new foyer(tasks, cb);%0A
   assert
@@ -396,16 +396,17 @@
 ions');%0A
+%0A
   cb = c
@@ -738,22 +738,25 @@
 f (err) 
-return
+%7B%0A       
  done = 
@@ -759,17 +759,33 @@
 e = true
-,
+; %0A        return
  cb(err)
@@ -785,16 +785,24 @@
 cb(err);
+%0A      %7D
 %0A%0A      

Add self instantiation, prevents possible reference conflicts