docs: function when(promises) {
  	promises = arrayify(promises);
  	var whenPromise = new PromiseFactory();
  
  	var pending = promises.length;
  	var results = [];
  
  	var resolve = function (i) {
  		return function (val) {
  			results[i] = val;
  			pending--;
  
  			if (pending === 0) {
  				whenPromise.resolve(results);
  			}
  		};
  	};
  
  	promises.forEach(function (p, i) {
  		if (!p || !p.then) return;
  
  		p.then(resolve(i), whenPromise.reject);
  	});
  
  	return whenPromise.promise();
  }