1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 08:38:06 +02:00

Use arrow function with various Array methods

A lot of this is quite old code, which we can shorten slightly by using arrow functions instead of "regular" functions.
This commit is contained in:
Jonas Jenwald 2025-03-02 14:48:08 +01:00
parent 7081a1f112
commit 2e62f426fe
10 changed files with 16 additions and 46 deletions

View file

@ -414,9 +414,7 @@ class ChunkedStreamManager {
}
}
chunksToRequest.sort(function (a, b) {
return a - b;
});
chunksToRequest.sort((a, b) => a - b);
return this._requestChunks(chunksToRequest);
}

View file

@ -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) {

View file

@ -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);

View file

@ -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() {