title: Bluebird promise library: are .map and .filter run in parallel?
body: <p>I'm attempting to write a bunch of async <code>fs</code> calls in <a href="https://github.com/petkaantonov/bluebird" rel="nofollow">bluebird promises</a>. It all works great except that I'm worried about performance. I can't tell if the <code>.map</code> and <code>.filter</code> functions are executing in parallel or sequentially. Here's my code:</p>
  
  <pre><code>var Promise = require('bluebird'),
    fs = Promise.promisifyAll(require('fs'));
  
  module.exports = getDirListing;
  
  function getDirListing(path) {
    function toFullPath(file) {
      return path + file;
    }
    function onlyDirs(file) {
      return fs.statAsync(file).then(function(file) {
        return !file.isFile();
      });
    }
    function ignoreHidden(name) {
      return !(name.substring(0,1) === '.');
    }
    function toModuleNames(dir) {
      return dir.replace(path, '');
    }
    return fs.readdirAsync(path)
      .map(toFullPath)
      .filter(onlyDirs)
      .map(toModuleNames)
      .filter(ignoreHidden);
  }
  </code></pre>
  
  <p>I especially care about the call to <code>onlyDirs</code> since that is making a bunch of async <code>fs.stat</code> calls and can/should be in parallel. I tried looking at <a href="https://github.com/petkaantonov/bluebird/blob/master/API.md#mapfunction-mapper---promise" rel="nofollow">their api docs</a> but I didn't see anything about parallelization.</p>
  
  <p>Note: I'm not currently in a position to use ECMAScript6 generators (unfortunately).</p>
  
  <p>Also, any other pointers on performance here are welcome.</p>