title: Refactor synchronous code to unleash the power of node.js asynchronicity
body: <p>We long-term Python and PHP coders have a tidy bit of synchronous code (sample below). Most of the functions have asynchronous counterparts. We really want to 'get' the power of Javascript and Node, and believe this is an ideal case of where asynchronous node.js would speed things up and blow our socks off.</p>
  
  <p>What is the textbook way to refactor the following to utilize asynchronous Node? <code>Async</code> / <code>await</code> and <code>promise.all</code>? How? (Using Node 8.4.0. Backwards compatibility is not a concern.)</p>
  
  <pre><code>var fs = require('fs');
  
  // This could list over 10,000 files of various size 
  const fileList = ['file1', 'file2', 'file3']; 
  
  const getCdate = file =&gt; fs.statSync(file).ctime; // Has async method
  
  const getFSize = file =&gt; fs.statSync(file).size; // Has async method
  
  // Can be async through file streams (see resources below)
  const getMd5 = (file) =&gt; {
    let fileData = new Buffer(0);
    fileData = fs.readFileSync(file);
    const hash = crypto.createHash('md5');
    hash.update(fileData);
    return hash.digest('hex');
  };
  
  let filesObj = fileList.map(file =&gt; [file, {
    datetime: getCdate(file),
    filesize: getFSize(file),
    md5hash: getMd5(file),
  }]);
  
  console.log(filesObj);
  </code></pre>
  
  <p>Notes: </p>
  
  <ul>
  <li>We need to keep the functions modular and re-usable.</li>
  <li>There are more functions getting things for <code>filesObj</code> than listed here</li>
  <li>Most functions can be re-written to be async, some can not.</li>
  <li>Ideally we need to keep the original order of <code>fileList</code>.</li>
  <li>Ideally we want to use latest Node and JS features -- not rely on external modules.</li>
  </ul>
  
  <hr>
  
  <p>Assorted file stream methods for getting md5 asynchronously: </p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/18658612">Obtaining the hash of a file using the stream capabilities of crypto module (ie: without hash.update and hash.digest)</a></li>
  <li><a href="https://stackoverflow.com/questions/768268">How to calculate md5 hash of a file using javascript</a></li>
  </ul>