Troubles with pdf.js promises
问题 I'm trying to implement a pdf word count in Javascript. I came across pdf.js which uses promises. Is there a way to wait till the script is done before returning the count? I know that this goes against the idea of promises, but the other js pdf readers out there either sometimes produce a bunch of gibberish or return nothing. In its current form the function always return a word count of 0. function countWords(pdfUrl){ var pdf = PDFJS.getDocument(pdfUrl); var count = 0; pdf.then(function(pdf