title: Node Promise return object with value of resolved promise
body: <p>I have some code below that will return all files in a directory with certain keys and values. One of those keys I want to be isDirectory with a boolean value.</p>
  
  <p>The code below works just fine, but I was wondering if there was a way to remove the Promise.all/iterating over promises and instead pushing the resolved value of the <code>stat.isDirectory()</code> to my files objects directly in my map.</p>
  
  <p><strong>My solution I tried but failed:</strong></p>
  
  <p>I tried something like this:</p>
  
  <pre><code>isDirectory: fs.statAsync(path).then((stat) =&gt; stat.isDirectory())
  </code></pre>
  
  <p>And then do a Promise.all on all the <code>isDirectory</code> keys</p>
  
  <p><strong>Working Code:</strong></p>
  
  <pre><code>const Promise = require('bluebird'),
      os = require('os'),
      _ = require('lodash'),
      fs = Promise.promisifyAll(require('fs')),
      desktopPath = `${os.homedir()}/Desktop`;
  
  let files = [];
  
  return fs.readdirAsync(desktopPath)
      .then((filesName) =&gt; files = _.map(filesName, (fileName) =&gt; ({
          path: `${desktopPath}/${fileName}`,
          name: fileName,
          ext: _.last(fileName.split('.'))
      })))
      .then(() =&gt; Promise.all(_.map(files, (file) =&gt; fs.statAsync(file.path))))
      .then((stats) =&gt; _.forEach(stats, (stat, idx) =&gt; {
          files[idx].isDirectory = stat.isDirectory();
      }))
      .then(() =&gt; {
          console.log(files);
      })
  </code></pre>
  
  <p>Is there anyway to remove the Promise.all and _.forEach part at the end? And instead do those actions in my map?</p>