title: How to control serial and parallel control flow with mapped functions?
body: <p>I've drawn a simple flow chart, which basically crawls some data from internet and loads them into the database. So far, I had thought I was peaceful with promises, however now I have an issue that I'm working for at least three days without a simple step.</p>
  
  <p>Here is the flow chart:</p>
  
  <p>Consider there is a static string array like so: <code>const courseCodes = ["ATA, "AKM", "BLG",... ]</code>.</p>
  
  <p>I have a <code>fetch</code> function, it basically does a HTTP request followed by parsing. Afterwards it returns some object array.</p>
  
  <p><code>fetch</code> works perfectly with invoking its callback with that expected object array, it even worked with Promises, which was way greater and tidy.</p>
  
  <p><code>fetch</code> function should be invoked with every element in the <code>courseCodes</code> array as its parameter. This task should be performed in parallel execution, since those seperate <code>fetch</code> functions do not affect each other.</p>
  
  <p>As a result, there should be a <code>results</code> array in callback (or <code>Promise</code>s resolve parameter), which includes array of array of objects. With those results, I should invoke my <code>loadCourse</code> with those objects in the <code>results</code> array as its parameter. Those tasks should be performed in serial execution, because it basically queries database if similar object exists, adds it if it's not.</p>
  
  <p>How can perform this kind of tasks in node.js? I could not maintain the asynchronous flow in such a scenario like this. I've failed with <code>caolan/async</code> library and <code>bluebird</code> &amp; <code>q</code> promise libraries.</p>