title: why isn't this promise resolving?
body: <p>I have a promise that is meant to collect metadata on a file and then resolve it with the metadata that was collected.  Here is how I am trying to get its result:</p>
  
  <pre><code>getMetadata: function(text, url){
      return this.getpageno(url).then(function(pagecount){
          return new Promise(function(accept, reject){
          var result = []
          var dataMatch = rx.exec(text)
          var produktDaten = dataMatch[1].split("&amp;&amp;&amp;").filter(Boolean);
          var dokuArr = dataMatch[2].split("&amp;&amp;&amp;").filter(Boolean);
          console.log('the produktdaten are ' + produktDaten)
          for (var i=0; i&lt;produktDaten.length; i+=4){
              var entry = {}
              for(var j=0; j&lt;dokuArr.length; j+=3){
  
              var seite = dokuArr[j+2];
              // make sure seite is a digit
              if (!(/^\d+$/.test(seite))){
                  console.log(seite + ' was not a valid page number')
                  throw err
              }
              if (/(A|a)lle?/i.test(nummer)){
                      entry.kks.pages[beschreibung] = seite;
  
                  //          })
              }
              else if (nummer === kksNummer) {
                  entry.kks.pages[beschreibung] = seite;
              }
              }
              entry.hersteller = produktDaten[i+1]
              entry.typ = produktDaten[i+2]
              entry.artikelNummer = produktDaten[i+3]
              result.push(entry)
          }
          if (result.length&gt;0){
              return accept(result)
          }
          return reject()
          })
      })
      },
      getpageno: function(url){
      var self=this
      var pdf = pdfjs.getDocument(url);        
      return pdf.then(function(pdf){       
          var maxPages = pdf.pdfInfo.numPages;
          var countPromises = []; // collecting all page promises
          for (var j = 1; j &lt;= maxPages; j++) {
          try {
              var page = pdf.getPage(j);
              var txt = "";
              countPromises.push(page.then(function(page) { // add page promise
              var textContent = page.getTextContent();
              return textContent.then(function(text){ // return content promise
                  return text.items.map(function (s) { return s.str; }).join('&amp;&amp;&amp;'); // value page text 
              });
              }));
          }
          catch(e){
              console.log(e)
          }
          }
          // Wait for all pages and join text
          return Promise.all(countPromises).then(function (texts) {
          // since doumentation pages do not add the final '&amp;&amp;&amp;', must add one manually (only after rx has been found)
          var fulltext = texts.reduce(function(full, text){                        
              if (rx.test(full)){
              var next = '&amp;&amp;&amp;'+text
              return full+=next
              }
              return full+=text            
          }, '')
          return [fulltext, texts]
          });      
      }).then(function(textarr){
          var fulltext = textarr[0]
          self.fulltext = fulltext;        
          var texts = textarr[1]
          try {
          var partialmatch = rx.exec(fulltext)[0]         
          var count = texts.reduce(function(pageno, text){
              var tomatch = text.replace(/.*Typ&amp;&amp;&amp;/, '')
              if (tomatch.length&gt;0 &amp;&amp; partialmatch.indexOf(tomatch) &gt; -1){
              pageno++
              }
              return pageno;
          }, 0)
          }
          catch(e){
          console.log(e)
          }
          return count;
      })
      }
  </code></pre>
  
  <p>Edited the entry to show that I'm now returning the value of the gepageno function.</p>
  
  <p>The data that I am expecting is logged but not available as a result of <code>accept()</code>.  Can anyone tell what could be going wrong?</p>