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:
parent
6e46304357
commit
9dfe9c552c
22 changed files with 78 additions and 169 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue