title: Concurrent chained javascript promises
body: <p>I have javascript promises A and C where B is a function that returns a promise. This is how I'd like them to flow:</p>
  
  <pre><code>A---&gt;B---&gt;
  C--------&gt;
            D------&gt;
  </code></pre>
  
  <p>B utilizes output from A, and D utilizes output from B and C</p>
  
  <p>My current code looks roughly as so:</p>
  
  <pre><code>var runPromises = [];
  runPromises.push(A.then(B));
  runPromises.push(C);
  
  Promise.all(runPromises).then(values =&gt; console.log(values));
  </code></pre>
  
  <p>What I'm seeing happen is A and C execute but B does not until after A and C are logged out. What is the proper pattern here for execution? Do A and B need to be put in an encompassing promise?</p>
  
  <blockquote>
    <p>To add on to my original question to explain Jaromanda's correct answer: My B function was defined roughly as so:</p>
  </blockquote>
  
  <pre><code>var B = function(inputA){
      return new Promise(function(resolve, reject){
          http.get(site, function(done){
              inputA['site'] = done;
          }
      resolve(inputA);
  </code></pre>
  
  <p>This was resolving inputA before the http.get could return and enrich inputA.</p>