title: Clean way of keeping an aggregate of a sequence of Q.all promises
body: <p>I would like to maintain an aggregate of intermediate results when executing a series of <code>Q.all</code> tasks.</p>
  
  <p>Concretely the problem is as follows:</p>
  
  <pre><code>var Obj = function(first, second) { 
      return { 
          stuff: first, 
          otherStuff: [1,2],
          nextStuff: function() { return Q.fcall(function() { return second }) }
      }
  };                                     
  
  var ab = Q.fcall(function() { return Obj("A", "B"); });
  var cd = Q.fcall(function() { return Obj("C", "D"); });
  
  var promises = [ab, cd];
  </code></pre>
  
  <p>What I would like is a result of <code>[{stuff: obj, nextStuff: "B"}, {stuff: obj, nextStuff: "D"}]</code></p>
  
  <p>Right now I keep a reference to the previous result and map over them using underscore.js like so</p>
  
  <pre><code>Q.all(promises).then(function(stuffs) { 
      var promiseNextStuff = _.map(stuffs, function(x) { return x.nextStuff(); });
      Q.all(promiseNextStuff).then(function(nextStuffs) { 
          var result = _.map(_.zip(stuffs, nextStuffs), function(obj) { 
              return _.object(["stuff", "nextStuff"], obj); 
          });
          console.log("result", result);
      });
  });
  </code></pre>
  
  <p>... but I'm sure there is a better way in Q</p>
  
  <p><a href="http://jsfiddle.net/joelkuiper/xY8Ew/2/" rel="nofollow">http://jsfiddle.net/joelkuiper/xY8Ew/2/</a></p>