From 36c01c2c2a7b20b651a15549f4205cc4c476689f Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 13 Oct 2019 14:21:39 +0200 Subject: [PATCH] Deduplicate the documentation for `PDFDocumentLoadingTask` and `PDFWorker` Both classes live inside a closure with the same name, which confuses JSDoc. Move the documentation to the inner class to deduplicate them. --- src/display/api.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index d6d41102f..0e585a24f 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -416,15 +416,14 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { }); } -/** - * PDF document loading operation. - * @class - * @alias PDFDocumentLoadingTask - */ const PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() { let nextDocumentId = 0; - /** @constructs PDFDocumentLoadingTask */ + /** + * The loading task controls the operations required to load a PDF document + * (such as network requests) and provides a way to listen for completion, + * after which individual pages can be rendered. + */ class PDFDocumentLoadingTask { constructor() { this._capability = createPromiseCapability(); @@ -1507,12 +1506,6 @@ class LoopbackPort { * constants from {VerbosityLevel} should be used. */ -/** - * PDF.js web worker abstraction, it controls instantiation of PDF documents and - * WorkerTransport for them. If creation of a web worker is not possible, - * a "fake" worker will be used instead. - * @class - */ const PDFWorker = (function PDFWorkerClosure() { const pdfWorkerPorts = new WeakMap(); let nextFakeWorkerId = 0; @@ -1590,9 +1583,15 @@ const PDFWorker = (function PDFWorkerClosure() { } /** - * @param {PDFWorkerParameters} params - The worker initialization parameters. + * PDF.js web worker abstraction, which controls the instantiation of PDF + * documents. Message handlers are used to pass information from the main + * thread to the worker thread and vice versa. If the creation of a web + * worker is not possible, a "fake" worker will be used instead. */ class PDFWorker { + /** + * @param {PDFWorkerParameters} params - Worker initialization parameters. + */ constructor({ name = null, port = null, verbosity = getVerbosityLevel(), } = {}) { if (port && pdfWorkerPorts.has(port)) {