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

Use more for...of loops in the code-base

Note that these cases, which are all in older code, were found using the [`unicorn/no-for-loop`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-for-loop.md) ESLint plugin rule.
However, note that I've opted not to enable this rule by default since there's still *some* cases where I do think that it makes sense to allow "regular" for-loops.
This commit is contained in:
Jonas Jenwald 2022-07-17 15:48:39 +02:00
parent 5bfba89b0a
commit 37ebc28756
14 changed files with 35 additions and 50 deletions

View file

@ -218,8 +218,8 @@ function parseCMap(binaryData) {
const sign = fromHexDigit(num[num.length - 1]) & 1 ? 15 : 0;
let c = 0;
let result = "";
for (let i = 0; i < num.length; i++) {
c = (c << 4) | fromHexDigit(num[i]);
for (const digit of num) {
c = (c << 4) | fromHexDigit(digit);
result += toHexDigit(sign ? (c >> 1) ^ sign : c >> 1);
c &= 1;
}