title: How to destructure results of a dynamic number of async calls with Promise.all
body: <p>I need to make an unknown number of async calls in parallel via <code>Promise.all</code>. Something similar to this:</p>
  
  <pre><code>let externalCalls = [call1()];
  if (someCondition1) {
    externalCalls.push(call2());
  }
  if (someCondition2) {
    externalCalls.push(call3());
  }
  </code></pre>
  
  <p>Then <code>externalCalls</code> will be passed to <code>Promise.all</code> so they can be run in parallel.</p>
  
  <p>Ideally, I'd like to use destructuring of the results so that I can refer to results by name, i.e.</p>
  
  <pre><code>const [call1, call2, call3] = await Promise.all(externalCalls);
  </code></pre>
  
  <p>I know <code>call1</code> will always be there, but I don't know if <code>call2</code> or <code>call3</code> will be there. So I'd like to define the <code>const</code> result of calling <code>await Promise.all</code> dynamically to have the correct properties, Is this possible? Or am I stuck having a generic results array of unknown length, and then having to inspect each item in the results to see which call produced it?</p>