title: Synchronously convert Blob to base64 string in Javascript
body: <p>The only way I found to base64 encode a data Blob to put it in a JSON string, is to use the <strong>asyncronous</strong> readAsDataUrl() function.</p>
  
  <pre><code>var reader = new window.FileReader();
  reader.readAsDataURL(blob); 
  reader.onloadend = function() {
      base64data = reader.result;                
      console.log(base64data );
  }
  </code></pre>
  
  <p>My problem is that I have to use a <strong>synchronous</strong> replacer function for <code>JSON.stringify(object, replacer)</code> to tell it how to seriealize Blobs.</p>
  
  <pre><code>var replacer = function (key, value) {
      if (value instanceof Blob) {
          return blobToBase64(value);
      }
      return value;
  }
  </code></pre>
  
  <p>How can I combine those two (asyncronous and synchronous) methods?</p>
  
  <p>Is there a better way to base64 encode those data <strong>synchronously</strong>?</p>