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
Most, if not all, of this code is old enough to predate the general availability of `for...of` iteration.
This commit is contained in:
parent
4e58dabb32
commit
60f6272ed9
16 changed files with 70 additions and 101 deletions
|
@ -112,8 +112,8 @@ const deferred = Promise.resolve();
|
|||
function normalizeBlendMode(value, parsingArray = false) {
|
||||
if (Array.isArray(value)) {
|
||||
// Use the first *supported* BM value in the Array (fixes issue11279.pdf).
|
||||
for (let i = 0, ii = value.length; i < ii; i++) {
|
||||
const maybeBM = normalizeBlendMode(value[i], /* parsingArray = */ true);
|
||||
for (const val of value) {
|
||||
const maybeBM = normalizeBlendMode(val, /* parsingArray = */ true);
|
||||
if (maybeBM) {
|
||||
return maybeBM;
|
||||
}
|
||||
|
@ -1056,10 +1056,8 @@ class PartialEvaluator {
|
|||
let isSimpleGState = true;
|
||||
// This array holds the converted/processed state data.
|
||||
const gStateObj = [];
|
||||
const gStateKeys = gState.getKeys();
|
||||
let promise = Promise.resolve();
|
||||
for (let i = 0, ii = gStateKeys.length; i < ii; i++) {
|
||||
const key = gStateKeys[i];
|
||||
for (const key of gState.getKeys()) {
|
||||
const value = gState.get(key);
|
||||
switch (key) {
|
||||
case "Type":
|
||||
|
@ -3419,8 +3417,8 @@ class PartialEvaluator {
|
|||
if (encoding.has("Differences")) {
|
||||
const diffEncoding = encoding.get("Differences");
|
||||
let index = 0;
|
||||
for (let j = 0, jj = diffEncoding.length; j < jj; j++) {
|
||||
const data = xref.fetchIfRef(diffEncoding[j]);
|
||||
for (const entry of diffEncoding) {
|
||||
const data = xref.fetchIfRef(entry);
|
||||
if (typeof data === "number") {
|
||||
index = data;
|
||||
} else if (data instanceof Name) {
|
||||
|
@ -4150,8 +4148,8 @@ class PartialEvaluator {
|
|||
if (widths) {
|
||||
const glyphWidths = [];
|
||||
let j = firstChar;
|
||||
for (let i = 0, ii = widths.length; i < ii; i++) {
|
||||
glyphWidths[j++] = this.xref.fetchIfRef(widths[i]);
|
||||
for (const width of widths) {
|
||||
glyphWidths[j++] = this.xref.fetchIfRef(width);
|
||||
}
|
||||
newProperties.widths = glyphWidths;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue