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:
commit
fce822cde0
37 changed files with 156 additions and 252 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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", () => {
|
||||
|
|
|
@ -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,
|
||||
}))
|
||||
: [];
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -377,9 +377,7 @@ describe("CFFCompiler", function () {
|
|||
bytes = new Uint8Array(bytes);
|
||||
return new CFFParser(
|
||||
{
|
||||
getBytes: () => {
|
||||
return bytes;
|
||||
},
|
||||
getBytes: () => bytes,
|
||||
},
|
||||
{},
|
||||
SEAC_ANALYSIS_ENABLED
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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)],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue