Skip to content

Commit

Permalink
Move the getPage call in PDFDocumentProperties class
Browse files Browse the repository at this point in the history
This allows us to remove an ESLint disable-statement for `arrow-body-style`, without affecting readability of the code, and fetching the metadata and the page in parallel should be a *tiny* bit more efficient as well.
  • Loading branch information
Snuffleupagus committed Dec 1, 2024
1 parent 8f08ca2 commit e5f744d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions web/pdf_document_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,13 @@ class PDFDocumentProperties {
}

// Get the document properties.
const {
info,
/* metadata, */
/* contentDispositionFilename, */
contentLength,
} = await this.pdfDocument.getMetadata();
const [
{ info, /* metadata, contentDispositionFilename, */ contentLength },
pdfPage,
] = await Promise.all([
this.pdfDocument.getMetadata(),
this.pdfDocument.getPage(currentPageNumber),
]);

const [
fileName,
Expand All @@ -131,10 +132,7 @@ class PDFDocumentProperties {
this.#parseFileSize(contentLength),
this.#parseDate(info.CreationDate),
this.#parseDate(info.ModDate),
// eslint-disable-next-line arrow-body-style
this.pdfDocument.getPage(currentPageNumber).then(pdfPage => {
return this.#parsePageSize(getPageSizeInches(pdfPage), pagesRotation);
}),
this.#parsePageSize(getPageSizeInches(pdfPage), pagesRotation),
this.#parseLinearization(info.IsLinearized),
]);

Expand Down

0 comments on commit e5f744d

Please sign in to comment.