Remove unneeded check in the "GetAnnotationsByType" worker-thread handler

Given that the Promise returned by the `PDFDocument.prototype.getPage` method *always* resolves with a `Page` instance, checking that the page is defined isn't necessary; note 3a09329113/src/core/document.js (L1702-L1723)

Furthermore the `Page.prototype.collectAnnotationsByType` method is asynchronous, and thus it always returns a Promise, hence it's "pointless" to fallback to return an empty Array.
This commit is contained in:
Jonas Jenwald 2026-06-15 13:12:47 +02:00
parent 3a09329113
commit d9e4cc5f65

View File

@ -510,20 +510,17 @@ class WorkerMessageHandler {
startWorkerTask(task);
}
pagePromises.push(
pdfManager.getPage(i).then(async page => {
if (!page) {
return [];
}
return (
pdfManager
.getPage(i)
.then(page =>
page.collectAnnotationsByType(
handler,
task,
types,
annotationPromises,
annotationGlobals
) || []
);
})
)
)
);
}
await Promise.all(pagePromises);