From 263bc08ccad7256b3db275b2bf2bc8e099cddbd2 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 14 Aug 2026 18:06:22 +0200 Subject: [PATCH] Shorten some `Array.prototype.map()` callbacks In a few spots we can directly pass the function, and don't need to create an "intermediate" arrow function. --- src/core/fonts.js | 2 +- src/core/struct_tree.js | 2 +- src/core/xfa/xhtml.js | 2 +- src/display/annotation_layer.js | 4 ++-- test/integration/freetext_editor_spec.mjs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/fonts.js b/src/core/fonts.js index 58e07bceaad7f..3601ac67af88f 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -966,7 +966,7 @@ function createNameTable(name, proto) { proto[0][8] || "Unknown", // 8.Manufacturer proto[0][9] || "Unknown", // 9.Designer ]; - const stringsBytes = strings.map(s => stringToBytes(s)); + const stringsBytes = strings.map(stringToBytes); // Mac want 1-byte per character strings while Windows want // 2-bytes per character, so duplicate the names table diff --git a/src/core/struct_tree.js b/src/core/struct_tree.js index 480b5ca58aa96..444ed650c17bc 100644 --- a/src/core/struct_tree.js +++ b/src/core/struct_tree.js @@ -728,7 +728,7 @@ class StructElementNode { if (Array.isArray(headers)) { const ids = headers .filter(header => typeof header === "string") - .map(header => stringToPDFString(header)); + .map(stringToPDFString); if (ids.length > 0) { map.set("headers", ids); } diff --git a/src/core/xfa/xhtml.js b/src/core/xfa/xhtml.js index d0f1cf34950c4..614c26aecbab5 100644 --- a/src/core/xfa/xhtml.js +++ b/src/core/xfa/xhtml.js @@ -265,7 +265,7 @@ class XhtmlObject extends XmlObject { xfaFont.letterSpacing = getMeasurement(value); break; case "margin": - const values = value.split(/ \t/).map(x => getMeasurement(x)); + const values = value.split(/ \t/).map(getMeasurement); switch (values.length) { case 1: margin.top = diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index c265c67de58d1..35a6fb145eecb 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -654,8 +654,8 @@ class AnnotationElement { return; } - const [rectBlX, rectBlY, rectTrX, rectTrY] = this.data.rect.map(x => - Math.fround(x) + const [rectBlX, rectBlY, rectTrX, rectTrY] = this.data.rect.map( + Math.fround ); if (quadPoints.length === 8) { diff --git a/test/integration/freetext_editor_spec.mjs b/test/integration/freetext_editor_spec.mjs index ada2868e2d29f..35aaa2e72bd9b 100644 --- a/test/integration/freetext_editor_spec.mjs +++ b/test/integration/freetext_editor_spec.mjs @@ -867,7 +867,7 @@ describe("FreeText Editor", () => { }, proprName); const rects = (await serialize("rect")).map(rect => - rect.slice(0, 2).map(x => Math.floor(x)) + rect.slice(0, 2).map(Math.floor) ); const expected = [ [-28, 695],