1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-24 09:08:07 +02:00

Use shorter arrow functions where possible

For arrow functions that are both simple and short, we can avoid using explicit `return` to shorten them even further without hurting readability.

For the `gulp mozcentral` build-target this reduces the overall size of the output by just under 1 kilo-byte (which isn't a lot but still can't hurt).
This commit is contained in:
Jonas Jenwald 2024-01-21 10:13:12 +01:00
parent 6e46304357
commit 9dfe9c552c
22 changed files with 78 additions and 169 deletions

View file

@ -237,9 +237,10 @@ describe("FreeText Editor", () => {
await clearAll(page);
for (const n of [0, 1, 2]) {
const hasEditor = await page.evaluate(sel => {
return !!document.querySelector(sel);
}, getEditorSelector(n));
const hasEditor = await page.evaluate(
sel => !!document.querySelector(sel),
getEditorSelector(n)
);
expect(hasEditor).withContext(`In ${browserName}`).toEqual(false);
}

View file

@ -942,14 +942,10 @@ describe("api", function () {
);
const loadingTask1 = getDocument(basicApiGetDocumentParams);
const promise1 = loadingTask1.promise.then(pdfDoc => {
return pdfDoc.numPages;
});
const promise1 = loadingTask1.promise.then(pdfDoc => pdfDoc.numPages);
const loadingTask2 = getDocument(tracemonkeyGetDocumentParams);
const promise2 = loadingTask2.promise.then(pdfDoc => {
return pdfDoc.numPages;
});
const promise2 = loadingTask2.promise.then(pdfDoc => pdfDoc.numPages);
const [numPages1, numPages2] = await Promise.all([promise1, promise2]);
expect(numPages1).toEqual(3);
@ -3901,9 +3897,9 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
true
);
expect(
currentImgData.data.every((value, index) => {
return value === firstImgData.data[index];
})
currentImgData.data.every(
(value, index) => value === firstImgData.data[index]
)
).toEqual(true);
if (i === NUM_PAGES_THRESHOLD) {

View file

@ -377,9 +377,7 @@ describe("CFFCompiler", function () {
bytes = new Uint8Array(bytes);
return new CFFParser(
{
getBytes: () => {
return bytes;
},
getBytes: () => bytes,
},
{},
SEAC_ANALYSIS_ENABLED

View file

@ -24,9 +24,7 @@ import { MessageHandler } from "../../src/shared/message_handler.js";
describe("message_handler", function () {
// Sleep function to wait for sometime, similar to setTimeout but faster.
function sleep(ticks) {
return Promise.resolve().then(() => {
return ticks && sleep(ticks - 1);
});
return Promise.resolve().then(() => ticks && sleep(ticks - 1));
}
describe("sendWithStream", function () {

View file

@ -62,9 +62,7 @@ describe("node_stream", function () {
const [start, end] = request.headers.range
.split("=")[1]
.split("-")
.map(x => {
return Number(x);
});
.map(x => Number(x));
const stream = fs.createReadStream(filePath, { start, end });
response.writeHead(206, {
"Content-Type": "application/pdf",

View file

@ -121,9 +121,7 @@ function testSearch({
}
}
const totalMatches = matchesPerPage.reduce((a, b) => {
return a + b;
});
const totalMatches = matchesPerPage.reduce((a, b) => a + b);
if (updateFindControlState) {
eventBus.on(

View file

@ -52,9 +52,9 @@ describe("Scripting", function () {
send_queue.set(command, { command, value });
};
// eslint-disable-next-line no-unsanitized/method
const promise = import(sandboxBundleSrc).then(pdfjsSandbox => {
return pdfjsSandbox.QuickJSSandbox();
});
const promise = import(sandboxBundleSrc).then(pdfjsSandbox =>
pdfjsSandbox.QuickJSSandbox()
);
sandbox = {
createSandbox(data) {
promise.then(sbx => sbx.create(data));