1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Use more optional chaining in the code-base

This patch updates a bunch of older code, that makes conditional function calls, to use optional chaining rather than `if`-blocks.

These mostly mechanical changes reduce the size of the `gulp mozcentral` build by a little over 1 kB.
This commit is contained in:
Jonas Jenwald 2022-09-05 15:36:04 +02:00
parent 9578152ae4
commit 38ee28b1d3
15 changed files with 51 additions and 119 deletions

View file

@ -854,9 +854,7 @@ function unitTestPostHandler(req, res) {
var onCancel = null,
ttxTimeout = 10000;
var timeoutId = setTimeout(function () {
if (onCancel) {
onCancel("TTX timeout");
}
onCancel?.("TTX timeout");
}, ttxTimeout);
translateFont(
body,
@ -1002,9 +1000,7 @@ function startBrowsers(initSessionCallback, makeStartUrl = null) {
session.browserPromise = startBrowser(browserName, startUrl)
.then(function (browser) {
session.browser = browser;
if (initSessionCallback) {
initSessionCallback(session);
}
initSessionCallback?.(session);
})
.catch(function (ex) {
console.log(`Error while starting ${browserName}: ${ex.message}`);
@ -1050,10 +1046,7 @@ async function closeSession(browser) {
const rimraf = require("rimraf");
rimraf.sync(tempDir);
}
if (onAllSessionsClosed) {
onAllSessionsClosed();
}
onAllSessionsClosed?.();
}
}
}