diff --git a/examples/text-only/pdf2svg.mjs b/examples/text-only/pdf2svg.mjs index f5184924d..497d5728c 100644 --- a/examples/text-only/pdf2svg.mjs +++ b/examples/text-only/pdf2svg.mjs @@ -30,7 +30,7 @@ function buildSVG(viewport, textContent) { svg.setAttribute("font-size", 1); // processing all items - textContent.items.forEach(function (textItem) { + textContent.items.forEach(textItem => { // we have to take in account viewport transform, which includes scale, // rotation and Y-axis flip, and not forgetting to flip text. const tx = pdfjsLib.Util.transform( diff --git a/extensions/chromium/options/options.js b/extensions/chromium/options/options.js index 977fefd27..25b21ab20 100644 --- a/extensions/chromium/options/options.js +++ b/extensions/chromium/options/options.js @@ -62,7 +62,7 @@ Promise.all([ var prefNames = Object.keys(schema); var renderPreferenceFunctions = {}; // Render options - prefNames.forEach(function (prefName) { + prefNames.forEach(prefName => { var prefSchema = schema[prefName]; if (!prefSchema.title) { // Don't show preferences if the title is missing. @@ -105,7 +105,7 @@ Promise.all([ document.getElementById("reset-button").onclick = function () { userPrefs = {}; storageArea.remove(prefNames, function () { - renderedPrefNames.forEach(function (prefName) { + renderedPrefNames.forEach(prefName => { renderPreferenceFunctions[prefName](getPrefValue(prefName)); }); }); @@ -120,7 +120,7 @@ Promise.all([ prefs = managedPrefs; } if (prefs) { - renderedPrefNames.forEach(function (prefName) { + renderedPrefNames.forEach(prefName => { var prefChanges = changes[prefName]; if (prefChanges) { if ("newValue" in prefChanges) { diff --git a/external/builder/test-fixtures.mjs b/external/builder/test-fixtures.mjs index df283c367..c1d05c01e 100644 --- a/external/builder/test-fixtures.mjs +++ b/external/builder/test-fixtures.mjs @@ -11,7 +11,7 @@ const files = fs .readdirSync(baseDir) .filter(name => /-expected\./.test(name)) .map(name => path.join(baseDir, name)); -files.forEach(function (expectationFilename) { +files.forEach(expectationFilename => { const inFilename = expectationFilename.replace("-expected", ""); const expectation = fs .readFileSync(expectationFilename) diff --git a/external/builder/test-fixtures_babel.mjs b/external/builder/test-fixtures_babel.mjs index c244c9ab8..9cf81f668 100644 --- a/external/builder/test-fixtures_babel.mjs +++ b/external/builder/test-fixtures_babel.mjs @@ -11,7 +11,7 @@ const files = fs .readdirSync(baseDir) .filter(name => /-expected\./.test(name)) .map(name => path.join(baseDir, name)); -files.forEach(function (expectationFilename) { +files.forEach(expectationFilename => { const inFilename = expectationFilename.replace("-expected", ""); const expectation = fs .readFileSync(expectationFilename) diff --git a/external/cmapscompress/compress.mjs b/external/cmapscompress/compress.mjs index 69e728a86..2733d5540 100644 --- a/external/cmapscompress/compress.mjs +++ b/external/cmapscompress/compress.mjs @@ -473,7 +473,7 @@ function compressCmaps(src, dest, verify) { const files = fs.readdirSync(src).filter( fn => !fn.includes(".") // skipping files with the extension ); - files.forEach(function (fn) { + files.forEach(fn => { const srcPath = path.join(src, fn); const destPath = path.join(dest, fn + ".bcmap"); const stats = compressCmap(srcPath, destPath, verify); diff --git a/gulpfile.mjs b/gulpfile.mjs index 9779415ad..891081e40 100644 --- a/gulpfile.mjs +++ b/gulpfile.mjs @@ -1384,7 +1384,7 @@ gulp.task("cmaps", async function () { } // Remove old bcmap files. - fs.readdirSync(VIEWER_CMAP_OUTPUT).forEach(function (file) { + fs.readdirSync(VIEWER_CMAP_OUTPUT).forEach(file => { if (/\.bcmap$/i.test(file)) { fs.unlinkSync(VIEWER_CMAP_OUTPUT + "/" + file); } diff --git a/src/core/cmap.js b/src/core/cmap.js index db483ebf4..04f9ac170 100644 --- a/src/core/cmap.js +++ b/src/core/cmap.js @@ -660,7 +660,7 @@ async function extendCMap(cMap, fetchBuiltInCMap, useCMap) { } // Merge the map into the current one, making sure not to override // any previously defined entries. - cMap.useCMap.forEach(function (key, value) { + cMap.useCMap.forEach((key, value) => { if (!cMap.contains(key)) { cMap.mapOne(key, value); } diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 3787805b1..b47953eae 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -4006,7 +4006,7 @@ class PartialEvaluator { }); const toUnicode = [], buf = []; - properties.cMap.forEach(function (charcode, cid) { + properties.cMap.forEach((charcode, cid) => { if (cid > 0xffff) { throw new FormatError("Max size of CID is 65,535"); } @@ -4060,7 +4060,7 @@ class PartialEvaluator { // Convert UTF-16BE // NOTE: cmap can be a sparse array, so use forEach instead of // `for(;;)` to iterate over all keys. - cmap.forEach(function (charCode, token) { + cmap.forEach((charCode, token) => { // Some cmaps contain *only* CID characters (fixes issue9367.pdf). if (typeof token === "number") { map[charCode] = String.fromCodePoint(token); diff --git a/src/core/fonts.js b/src/core/fonts.js index 594bee4ed..574a10dac 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -1340,7 +1340,7 @@ class Font { properties.hasIncludedToUnicodeMap && this.toUnicode instanceof IdentityToUnicodeMap ) { - this.toUnicode.forEach(function (charCode, unicodeCharCode) { + this.toUnicode.forEach((charCode, unicodeCharCode) => { const cid = map[charCode]; if (cidToGidMap[cid] === undefined) { map[charCode] = unicodeCharCode; @@ -1350,7 +1350,7 @@ class Font { } if (!(this.toUnicode instanceof IdentityToUnicodeMap)) { - this.toUnicode.forEach(function (charCode, unicodeCharCode) { + this.toUnicode.forEach((charCode, unicodeCharCode) => { map[charCode] = unicodeCharCode; }); } @@ -1385,7 +1385,7 @@ class Font { !this.cidEncoding.startsWith("Identity-") && !(this.toUnicode instanceof IdentityToUnicodeMap) ) { - this.toUnicode.forEach(function (charCode, unicodeCharCode) { + this.toUnicode.forEach((charCode, unicodeCharCode) => { map[charCode] = unicodeCharCode; }); } @@ -3039,7 +3039,7 @@ class Font { const cidToGidMap = properties.cidToGidMap || []; const isCidToGidMapEmpty = cidToGidMap.length === 0; - properties.cMap.forEach(function (charCode, cid) { + properties.cMap.forEach((charCode, cid) => { if (typeof cid === "string") { cid = convertCidString(charCode, cid, /* shouldThrow = */ true); } diff --git a/test/chromium/test-telemetry.js b/test/chromium/test-telemetry.js index 7ed83ab84..b315b0cbe 100755 --- a/test/chromium/test-telemetry.js +++ b/test/chromium/test-telemetry.js @@ -96,7 +96,7 @@ function createExtensionGlobal() { }; window.Headers = function (headers) { headers = JSON.parse(JSON.stringify(headers)); // Clone. - Object.keys(headers).forEach(function (k) { + Object.keys(headers).forEach(k => { headers[k] = String(headers[k]); }); return headers; @@ -142,7 +142,7 @@ function createExtensionGlobal() { }; window.test_fireTimers = function () { assert.ok(timers.length); - timers.forEach(function (timer) { + timers.forEach(timer => { timer(); }); }; diff --git a/test/stats/statcmp.js b/test/stats/statcmp.js index 5cf20b05b..431131457 100644 --- a/test/stats/statcmp.js +++ b/test/stats/statcmp.js @@ -48,8 +48,8 @@ function group(stats, groupBy) { */ function flatten(stats) { let rows = []; - stats.forEach(function (curStat) { - curStat.stats.forEach(function (s) { + stats.forEach(curStat => { + curStat.stats.forEach(s => { rows.push({ browser: curStat.browser, page: curStat.page, diff --git a/test/test.mjs b/test/test.mjs index 7febe2533..05e0eec7b 100644 --- a/test/test.mjs +++ b/test/test.mjs @@ -240,7 +240,7 @@ async function startRefTest(masterMode, showRefImages) { var numFBFFailures = 0; var numEqFailures = 0; var numEqNoSnapshot = 0; - sessions.forEach(function (session) { + sessions.forEach(session => { numRuns += session.numRuns; numErrors += session.numErrors; numFBFFailures += session.numFBFFailures; @@ -699,8 +699,8 @@ async function checkRefTestResults(browser, id, results) { var task = session.tasks[id]; session.numRuns++; - results.forEach(function (roundResults, round) { - roundResults.forEach(function (pageResult, page) { + results.forEach((roundResults, round) => { + roundResults.forEach((pageResult, page) => { if (!pageResult) { return; // no results } @@ -760,8 +760,8 @@ async function checkRefTestResults(browser, id, results) { } } // Clear snapshot buffers and drop the task entry from the session. - results.forEach(function (roundResults) { - roundResults.forEach(function (pageResult) { + results.forEach(roundResults => { + roundResults.forEach(pageResult => { if (pageResult) { pageResult.snapshot = null; pageResult.baselineSnapshot = null; @@ -853,7 +853,7 @@ function onAllSessionsClosedAfterTests(name) { stopServer(); var numRuns = 0, numErrors = 0; - sessions.forEach(function (session) { + sessions.forEach(session => { numRuns += session.numRuns; numErrors += session.numErrors; }); diff --git a/test/testutils.mjs b/test/testutils.mjs index 70a37f471..c1bceb9c7 100644 --- a/test/testutils.mjs +++ b/test/testutils.mjs @@ -21,7 +21,7 @@ function copySubtreeSync(src, dest) { if (!fs.existsSync(dest)) { fs.mkdirSync(dest); } - files.forEach(function (filename) { + files.forEach(filename => { const srcFile = path.join(src, filename); const file = path.join(dest, filename); const stats = fs.statSync(srcFile);