mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +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
|
@ -1764,9 +1764,7 @@ const PDFViewerApplication = {
|
|||
.catch(() => {
|
||||
/* Avoid breaking printing; ignoring errors. */
|
||||
})
|
||||
.then(() => {
|
||||
return this.pdfDocument?.annotationStorage.print;
|
||||
});
|
||||
.then(() => this.pdfDocument?.annotationStorage.print);
|
||||
|
||||
if (this.printService) {
|
||||
// There is no way to suppress beforePrint/afterPrint events,
|
||||
|
|
|
@ -54,9 +54,7 @@ function addLinkAttributes(link, { url, target, rel, enabled = true } = {}) {
|
|||
} else {
|
||||
link.href = "";
|
||||
link.title = `Disabled: ${url}`;
|
||||
link.onclick = () => {
|
||||
return false;
|
||||
};
|
||||
link.onclick = () => false;
|
||||
}
|
||||
|
||||
let targetStr = ""; // LinkTarget.NONE
|
||||
|
|
|
@ -30,13 +30,9 @@ class PDFScriptingManagerComponents extends PDFScriptingManager {
|
|||
}
|
||||
|
||||
options.externalServices ||= {
|
||||
createScripting: () => {
|
||||
return new GenericScripting(options.sandboxBundleSrc);
|
||||
},
|
||||
};
|
||||
options.docProperties ||= pdfDocument => {
|
||||
return docProperties(pdfDocument);
|
||||
createScripting: () => new GenericScripting(options.sandboxBundleSrc),
|
||||
};
|
||||
options.docProperties ||= pdfDocument => docProperties(pdfDocument);
|
||||
super(options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,20 +206,18 @@ function parseQueryString(query) {
|
|||
return params;
|
||||
}
|
||||
|
||||
const InvisibleCharactersRegExp = /[\x00-\x1F]/g;
|
||||
const InvisibleCharsRegExp = /[\x00-\x1F]/g;
|
||||
|
||||
/**
|
||||
* @param {string} str
|
||||
* @param {boolean} [replaceInvisible]
|
||||
*/
|
||||
function removeNullCharacters(str, replaceInvisible = false) {
|
||||
if (!InvisibleCharactersRegExp.test(str)) {
|
||||
if (!InvisibleCharsRegExp.test(str)) {
|
||||
return str;
|
||||
}
|
||||
if (replaceInvisible) {
|
||||
return str.replaceAll(InvisibleCharactersRegExp, m => {
|
||||
return m === "\x00" ? "" : " ";
|
||||
});
|
||||
return str.replaceAll(InvisibleCharsRegExp, m => (m === "\x00" ? "" : " "));
|
||||
}
|
||||
return str.replaceAll("\x00", "");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue