diff --git a/src/core/chunked_stream.js b/src/core/chunked_stream.js index b4ebe5b64..c77f62531 100644 --- a/src/core/chunked_stream.js +++ b/src/core/chunked_stream.js @@ -414,9 +414,7 @@ class ChunkedStreamManager { } } - chunksToRequest.sort(function (a, b) { - return a - b; - }); + chunksToRequest.sort((a, b) => a - b); return this._requestChunks(chunksToRequest); } diff --git a/src/core/fonts.js b/src/core/fonts.js index 8ebdcb810..a2e090d61 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -576,9 +576,7 @@ function getRanges(glyphs, toUnicodeExtraMap, numGlyphs) { if (codes.length === 0) { codes.push({ fontCharCode: 0, glyphId: 0 }); } - codes.sort(function fontGetRangesSort(a, b) { - return a.fontCharCode - b.fontCharCode; - }); + codes.sort((a, b) => a.fontCharCode - b.fontCharCode); // Split the sorted codes into ranges. const ranges = []; @@ -1777,9 +1775,7 @@ class Font { } // removing duplicate entries - mappings.sort(function (a, b) { - return a.charCode - b.charCode; - }); + mappings.sort((a, b) => a.charCode - b.charCode); const finalMappings = [], seenCharCodes = new Set(); for (const map of mappings) { diff --git a/src/core/jbig2.js b/src/core/jbig2.js index 448f23e4f..df689d963 100644 --- a/src/core/jbig2.js +++ b/src/core/jbig2.js @@ -374,9 +374,7 @@ function decodeBitmap( // Sorting is non-standard, and it is not required. But sorting increases // the number of template bits that can be reused from the previous // contextLabel in the main loop. - template.sort(function (a, b) { - return a.y - b.y || a.x - b.x; - }); + template.sort((a, b) => a.y - b.y || a.x - b.x); const templateLength = template.length; const templateX = new Int8Array(templateLength); diff --git a/src/core/xml_parser.js b/src/core/xml_parser.js index a1a60bf06..665c46828 100644 --- a/src/core/xml_parser.js +++ b/src/core/xml_parser.js @@ -321,11 +321,7 @@ class SimpleDOMNode { if (!this.childNodes) { return this.nodeValue || ""; } - return this.childNodes - .map(function (child) { - return child.textContent; - }) - .join(""); + return this.childNodes.map(child => child.textContent).join(""); } get children() { diff --git a/test/font/jasmine-boot.js b/test/font/jasmine-boot.js index a8b81ded0..71e1ba496 100644 --- a/test/font/jasmine-boot.js +++ b/test/font/jasmine-boot.js @@ -49,10 +49,7 @@ async function initializePDFJS(callback) { "pdfjs-test/font/font_os2_spec.js", "pdfjs-test/font/font_post_spec.js", "pdfjs-test/font/font_fpgm_spec.js", - ].map(function (moduleName) { - // eslint-disable-next-line no-unsanitized/method - return import(moduleName); - }) + ].map(moduleName => import(moduleName)) // eslint-disable-line no-unsanitized/method ); callback(); diff --git a/test/stats/statcmp.js b/test/stats/statcmp.js index e5ba75441..eca8457bb 100644 --- a/test/stats/statcmp.js +++ b/test/stats/statcmp.js @@ -64,9 +64,7 @@ function flatten(stats) { }); // Use only overall results if not grouped by 'stat' if (!options.groupBy.includes("stat")) { - rows = rows.filter(function (s) { - return s.stat === "Overall"; - }); + rows = rows.filter(s => s.stat === "Overall"); } return rows; } @@ -129,9 +127,7 @@ function stat(baseline, current) { } const rows = []; // collect rows and measure column widths - const width = labels.map(function (s) { - return s.length; - }); + const width = labels.map(s => s.length); rows.push(labels); for (const key of keys) { const baselineMean = mean(baselineGroup[key]); @@ -162,9 +158,7 @@ function stat(baseline, current) { } // add horizontal line - const hline = width.map(function (w) { - return new Array(w + 1).join("-"); - }); + const hline = width.map(w => new Array(w + 1).join("-")); rows.splice(1, 0, hline); // print output diff --git a/test/test.mjs b/test/test.mjs index d685dce9d..d837f46ac 100644 --- a/test/test.mjs +++ b/test/test.mjs @@ -1051,9 +1051,7 @@ async function closeSession(browser) { await session.browser.close(); } session.closed = true; - const allClosed = sessions.every(function (s) { - return s.closed; - }); + const allClosed = sessions.every(s => s.closed); if (allClosed) { if (tempDir) { fs.rmSync(tempDir, { recursive: true, force: true }); diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index 5532cf7a5..8c991f0c6 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -4869,9 +4869,9 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`) // Issue 6205 reported an issue with font rendering, so clear the loaded // fonts so that we can see whether loading PDFs in parallel does not // cause any issues with the rendered fonts. - const destroyPromises = loadingTasks.map(function (loadingTask) { - return loadingTask.destroy(); - }); + const destroyPromises = loadingTasks.map(loadingTask => + loadingTask.destroy() + ); await Promise.all(destroyPromises); }); diff --git a/test/unit/jasmine-boot.js b/test/unit/jasmine-boot.js index 72751cdf2..7dd0a0986 100644 --- a/test/unit/jasmine-boot.js +++ b/test/unit/jasmine-boot.js @@ -100,10 +100,7 @@ async function initializePDFJS(callback) { "pdfjs-test/unit/xfa_serialize_data_spec.js", "pdfjs-test/unit/xfa_tohtml_spec.js", "pdfjs-test/unit/xml_spec.js", - ].map(function (moduleName) { - // eslint-disable-next-line no-unsanitized/method - return import(moduleName); - }) + ].map(moduleName => import(moduleName)) // eslint-disable-line no-unsanitized/method ); if (isNodeJS) { diff --git a/web/debugger.mjs b/web/debugger.mjs index 59c1871b3..c85b31f7a 100644 --- a/web/debugger.mjs +++ b/web/debugger.mjs @@ -398,9 +398,7 @@ class Stepper { } getNextBreakPoint() { - this.breakPoints.sort(function (a, b) { - return a - b; - }); + this.breakPoints.sort((a, b) => a - b); for (const breakPoint of this.breakPoints) { if (breakPoint > this.currentIdx) { return breakPoint; @@ -487,9 +485,7 @@ const Stats = (function Stats() { statsDiv.textContent = stat.toString(); wrapper.append(title, statsDiv); stats.push({ pageNumber, div: wrapper }); - stats.sort(function (a, b) { - return a.pageNumber - b.pageNumber; - }); + stats.sort((a, b) => a.pageNumber - b.pageNumber); clear(this.panel); for (const entry of stats) { this.panel.append(entry.div);