title: How to download files using javascript asynchronously?
body: <p>I'm building a Chrome extension to download a series of files from a site. The downloading function is derived from <a href="http://ausdemmaschinenraum.wordpress.com/2012/12/06/how-to-save-a-file-from-a-url-with-javascript/" rel="nofollow noreferrer">How to save a file from a URL with JavaScript</a>.</p>
  <p>The program structure is like:</p>
  <pre><code>function download()
  {
    while(there are still files to download)
    {
      saveFile(url);
    }
  }
  </code></pre>
  <p>But I find that all the files are actually written to disk at once after <code>download()</code> returns. And the addresses of those files start with <code>blob:</code> when examine from Chrome's downloads manager.</p>
  <p>I wonder if I make the call to <code>saveFile</code> asynchronously, those files could be written one at a time.</p>