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

Merge pull request #17550 from Snuffleupagus/arrow-fn-shorter

Use shorter arrow functions where possible
This commit is contained in:
Jonas Jenwald 2024-01-21 17:21:32 +01:00 committed by GitHub
commit fce822cde0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 156 additions and 252 deletions

View file

@ -106,6 +106,7 @@ async function inlineImages(node, silentErrors = false) {
}
return response.blob();
})
// eslint-disable-next-line arrow-body-style
.then(blob => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
@ -117,6 +118,7 @@ async function inlineImages(node, silentErrors = false) {
reader.readAsDataURL(blob);
});
})
// eslint-disable-next-line arrow-body-style
.then(dataUrl => {
return new Promise((resolve, reject) => {
image.onload = resolve;

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

@ -38,8 +38,8 @@ const getXY = (page, selector) =>
return `${bbox.x}::${bbox.y}`;
}, selector);
const getSpanRectFromText = (page, pageNumber, text) => {
return page.evaluate(
const getSpanRectFromText = (page, pageNumber, text) =>
page.evaluate(
(number, content) => {
for (const el of document.querySelectorAll(
`.page[data-page-number="${number}"] > .textLayer > span`
@ -54,7 +54,6 @@ const getSpanRectFromText = (page, pageNumber, text) => {
pageNumber,
text
);
};
describe("Highlight Editor", () => {
describe("Editor must be removed without exception", () => {

View file

@ -265,9 +265,10 @@ async function serializeBitmapDimensions(page) {
const { map } =
window.PDFViewerApplication.pdfDocument.annotationStorage.serializable;
return map
? Array.from(map.values(), x => {
return { width: x.bitmap.width, height: x.bitmap.height };
})
? Array.from(map.values(), x => ({
width: x.bitmap.width,
height: x.bitmap.height,
}))
: [];
});
}

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);
@ -2693,9 +2689,7 @@ describe("api", function () {
const viewPromises = [];
for (let i = 0; i < numPages; i++) {
viewPromises[i] = pdfDoc.getPage(i + 1).then(pdfPage => {
return pdfPage.view;
});
viewPromises[i] = pdfDoc.getPage(i + 1).then(pdfPage => pdfPage.view);
}
const [page1, page2, page3] = await Promise.all(viewPromises);
@ -3416,7 +3410,9 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
})
);
// eslint-disable-next-line arrow-body-style
const result1 = loadingTask1.promise.then(pdfDoc => {
// eslint-disable-next-line arrow-body-style
return pdfDoc.getPage(1).then(pdfPage => {
return pdfPage.getOperatorList().then(opList => {
expect(opList.fnArray.length).toBeGreaterThan(100);
@ -3429,7 +3425,9 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
});
});
// eslint-disable-next-line arrow-body-style
const result2 = loadingTask2.promise.then(pdfDoc => {
// eslint-disable-next-line arrow-body-style
return pdfDoc.getPage(1).then(pdfPage => {
return pdfPage.getOperatorList().then(opList => {
expect(opList.fnArray.length).toEqual(0);
@ -3901,9 +3899,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));
@ -152,14 +152,12 @@ describe("Scripting", function () {
});
it("should get field using a path", async () => {
const base = value => {
return {
id: getId(),
value,
actions: {},
type: "text",
};
};
const base = value => ({
id: getId(),
value,
actions: {},
type: "text",
});
const data = {
objects: {
A: [base(1)],