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

Combine Array.from and Array.prototype.map calls

This isn't just a tiny bit more compact, but it also avoids an intermediate allocation; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#description
This commit is contained in:
Jonas Jenwald 2022-10-28 13:46:30 +02:00
parent 27b251ac99
commit ba05e47b3e
2 changed files with 16 additions and 17 deletions

View file

@ -88,9 +88,8 @@ function getPdfColor(color, isFill) {
return `${numberToString(gray)} ${isFill ? "g" : "G"}`;
}
return (
Array.from(color)
.map(c => numberToString(c / 255))
.join(" ") + ` ${isFill ? "rg" : "RG"}`
Array.from(color, c => numberToString(c / 255)).join(" ") +
` ${isFill ? "rg" : "RG"}`
);
}