docs: function all (promises) {
  
      var done      = new promise.Promise,
          successes = [],
          failures  = [],
          failed    = false,
          completed = 0,
          total     = promises.length;
  
      if (promises.length === 0) {
          done.resolve([]);
          return done;
      }
  
      var check = function () {
          if (++completed < total) {
              return;
          }
          if (failures.length) {
              failures.successes = successes;
              done.reject(failures);
          }
          else {
              done.resolve(successes);
          }
      };
  
      for (var i = 0; i < total; i++) {
          promise.when(promises[i], function (result) {
              successes[i] = result;
              check();
          }, function (error) {
              failures[i] = error;
              check();
          });
      }
  
      return done;
  }