title: Need help parsing id3 tags asyncrhonously in node.js using id3-parser
body: <p>I have a folder full of mp3s that I would like to parse using id3-parser npm module so that I can return an rss feed. The id3-parser documentation says to use this structure:</p>
  
  <pre><code>id3.parse(filebuffer).then(function(tag){
    console.log(tag.title);
  });
  </code></pre>
  
  <p>The id3-parser module uses the promise-a-plus module. The problem with my code is that the tag gets read at the very end of the stack. Here is my test code:</p>
  
  <pre><code>var id3 = require('id3-parser');
  var fs = require('fs');
  
  fs.readdir("podcasts", function (err, files) {
    files.forEach( function (file) {
      var stats = fs.statSync("podcasts/" + file);
      if (stats.isFile()) {
        var fbuff = fs.readFileSync("podcasts/" + file);
        id3.parse(fbuff).then( function (tag) {
          console.log("***"+tag.title);
        });
        console.log("Parsed id3 tag " + file);
      }
      console.log("Done file");
    });
    console.log("Done readdir");
  });
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>Parsed id3 tag test.mp3
  Done file
  Done readdir
  ***Title tag
  </code></pre>
  
  <p>I cannot for the life of me figure out how to properly wait for the tag to be parsed. Parsing should happen before I put it into the rss feed (have no trouble using the rss module to create that xml feed -- code not shown). I have been reading about promises and I am missing something. I am sure I just need to completely refactor my code, but not sure how to read every file (currently using readdir and forEach) and add each file to the feed.</p>