mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Add support for async
/await
using Babel
For proof-of-concept, this patch converts a couple of `Promise` returning methods to use `async` instead. Please note that the `generic` build, based on this patch, has been successfully testing in IE11 (i.e. the viewer loads and nothing is obviously broken). Being able to use modern JavaScript features like `async`/`await` is a huge plus, but there's one (obvious) side-effect: The size of the built files will increase slightly (unless `SKIP_BABEL == true`). That's unavoidable, but seems like a small price to pay in the grand scheme of things. Finally, note that the `chromium` build target was changed to no longer skip Babel translation, since the Chrome extension still supports version `49` of the browser (where native `async` support isn't available).
This commit is contained in:
parent
4ea663aa8a
commit
099ed08852
13 changed files with 159 additions and 179 deletions
|
@ -131,19 +131,17 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
this.options = options || DefaultPartialEvaluatorOptions;
|
||||
this.pdfFunctionFactory = pdfFunctionFactory;
|
||||
|
||||
this.fetchBuiltInCMap = (name) => {
|
||||
this.fetchBuiltInCMap = async (name) => {
|
||||
if (this.builtInCMapCache.has(name)) {
|
||||
return Promise.resolve(this.builtInCMapCache.get(name));
|
||||
return this.builtInCMapCache.get(name);
|
||||
}
|
||||
return this.handler.sendWithPromise('FetchBuiltInCMap', {
|
||||
name,
|
||||
}).then((data) => {
|
||||
if (data.compressionType !== CMapCompressionType.NONE) {
|
||||
// Given the size of uncompressed CMaps, only cache compressed ones.
|
||||
this.builtInCMapCache.set(name, data);
|
||||
}
|
||||
return data;
|
||||
});
|
||||
const data = await this.handler.sendWithPromise('FetchBuiltInCMap',
|
||||
{ name, });
|
||||
if (data.compressionType !== CMapCompressionType.NONE) {
|
||||
// Given the size of uncompressed CMaps, only cache compressed ones.
|
||||
this.builtInCMapCache.set(name, data);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue