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

Enable the unicorn/prefer-at ESLint plugin rule (PR 15008 follow-up)

Please find additional information here:
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at
 - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-at.md
This commit is contained in:
Jonas Jenwald 2022-06-09 12:53:39 +02:00
parent 5d88233fbb
commit 9ac4536693
32 changed files with 56 additions and 46 deletions

View file

@ -278,7 +278,7 @@ function compileGlyf(code, cmds, font) {
}
const instructionLength = getUint16(code, i);
i += 2 + instructionLength; // skipping the instructions
const numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
const numberOfPoints = endPtsOfContours.at(-1) + 1;
const points = [];
while (points.length < numberOfPoints) {
flags = code[i++];
@ -329,15 +329,15 @@ function compileGlyf(code, cmds, font) {
const contour = points.slice(startPoint, endPoint + 1);
if (contour[0].flags & 1) {
contour.push(contour[0]); // using start point at the contour end
} else if (contour[contour.length - 1].flags & 1) {
} else if (contour.at(-1).flags & 1) {
// first is off-curve point, trying to use one from the end
contour.unshift(contour[contour.length - 1]);
contour.unshift(contour.at(-1));
} else {
// start and end are off-curve points, creating implicit one
const p = {
flags: 1,
x: (contour[0].x + contour[contour.length - 1].x) / 2,
y: (contour[0].y + contour[contour.length - 1].y) / 2,
x: (contour[0].x + contour.at(-1).x) / 2,
y: (contour[0].y + contour.at(-1).y) / 2,
};
contour.unshift(p);
contour.push(p);