Skip to content

Commit

Permalink
Reduce duplication in the PDFDocument.calculationOrderIds getter
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuffleupagus committed Oct 8, 2024
1 parent e3b5ed2 commit 662bd02
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/core/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -1947,12 +1947,7 @@ class PDFDocument {
}

get calculationOrderIds() {
const acroForm = this.catalog.acroForm;
if (!acroForm?.has("CO")) {
return shadow(this, "calculationOrderIds", null);
}

const calculationOrder = acroForm.get("CO");
const calculationOrder = this.catalog.acroForm?.get("CO");
if (!Array.isArray(calculationOrder) || calculationOrder.length === 0) {
return shadow(this, "calculationOrderIds", null);
}
Expand All @@ -1963,10 +1958,7 @@ class PDFDocument {
ids.push(id.toString());
}
}
if (ids.length === 0) {
return shadow(this, "calculationOrderIds", null);
}
return shadow(this, "calculationOrderIds", ids);
return shadow(this, "calculationOrderIds", ids.length ? ids : null);
}

get annotationGlobals() {
Expand Down

0 comments on commit 662bd02

Please sign in to comment.