1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Use arrow functions with some Promise.then calls

A lot of this is fairly old code, which we can shorten slightly by using arrow functions instead of "regular" functions.
This commit is contained in:
Jonas Jenwald 2025-03-02 18:58:52 +01:00
parent 3cd1b10433
commit 7b5cd9cddd
5 changed files with 63 additions and 80 deletions

View file

@ -1164,9 +1164,7 @@ class Annotation {
}
const objectLoader = new ObjectLoader(resources, keys, resources.xref);
return objectLoader.load().then(function () {
return resources;
});
return objectLoader.load().then(() => resources);
});
}

View file

@ -1475,9 +1475,7 @@ class Catalog {
if (!found) {
throw new FormatError("Kid reference not found in parent's kids.");
}
return Promise.all(kidPromises).then(function () {
return [total, parentRef];
});
return Promise.all(kidPromises).then(() => [total, parentRef]);
});
}

View file

@ -546,9 +546,7 @@ class Page {
resources: this.resources,
operatorList: opList,
})
.then(function () {
return opList;
});
.then(() => opList);
});
// Fetch the page's annotations and add their operator lists to the

View file

@ -450,9 +450,9 @@ class WorkerMessageHandler {
});
handler.on("GetPageJSActions", function ({ pageIndex }) {
return pdfManager.getPage(pageIndex).then(function (page) {
return pdfManager.ensure(page, "jsActions");
});
return pdfManager
.getPage(pageIndex)
.then(page => pdfManager.ensure(page, "jsActions"));
});
handler.on("GetOutline", function (data) {
@ -479,9 +479,7 @@ class WorkerMessageHandler {
});
handler.on("GetData", function (data) {
return pdfManager.requestLoadedStream().then(function (stream) {
return stream.bytes;
});
return pdfManager.requestLoadedStream().then(stream => stream.bytes);
});
handler.on("GetAnnotations", function ({ pageIndex, intent }) {
@ -812,9 +810,9 @@ class WorkerMessageHandler {
});
handler.on("GetStructTree", function (data) {
return pdfManager.getPage(data.pageIndex).then(function (page) {
return pdfManager.ensure(page, "getStructTree");
});
return pdfManager
.getPage(data.pageIndex)
.then(page => pdfManager.ensure(page, "getStructTree"));
});
handler.on("FontFallback", function (data) {
@ -872,9 +870,9 @@ class WorkerMessageHandler {
return pdfManager.ensureDoc("startXRef");
});
handler.on("GetAnnotArray", function (data) {
return pdfManager.getPage(data.pageIndex).then(function (page) {
return page.annotations.map(a => a.toString());
});
return pdfManager
.getPage(data.pageIndex)
.then(page => page.annotations.map(a => a.toString()));
});
}