From ea4b1623283bb30e0bdc6035b7ff58ab4471273c Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 27 Jun 2021 11:34:59 +0200 Subject: [PATCH 1/2] Use the `RefProxy` typedef in more JSDoc comments in `src/display/api.js` --- src/display/api.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index 3363923b194c7..f06cb3142503f 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -114,6 +114,12 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) { * } TypedArray */ +/** + * @typedef {Object} RefProxy + * @property {number} num + * @property {number} gen + */ + /** * Document initialization / loading parameters object. * @@ -761,12 +767,6 @@ class PDFDocumentProxy { return this._transport.getPage(pageNumber); } - /** - * @typedef {Object} RefProxy - * @property {number} num - * @property {number} gen - */ - /** * @param {RefProxy} ref - The page reference. * @returns {Promise} A promise that is resolved with the page index, @@ -1231,8 +1231,7 @@ class PDFPageProxy { } /** - * @type {Object} The reference that points to this page. It has `num` and - * `gen` properties. + * @type {RefProxy | null} The reference that points to this page. */ get ref() { return this._pageInfo.ref; From d02146b13bc4701d15d4249299b7ae47296f84f2 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 27 Jun 2021 11:50:52 +0200 Subject: [PATCH 2/2] Add a `OnProgressParameters` typedef to reduce (some) duplication in `src/display/api.js` --- src/display/api.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index f06cb3142503f..8e69941de0865 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -514,6 +514,12 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { }); } +/** + * @typedef {Object} OnProgressParameters + * @property {number} loaded - Currently loaded number of bytes. + * @property {number} total - Total number of bytes in the PDF file. + */ + /** * The loading task controls the operations required to load a PDF document * (such as network requests) and provides a way to listen for completion, @@ -528,8 +534,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { * {@link PasswordResponses}). * @property {function} [onProgress] - Callback to be able to monitor the * loading progress of the PDF file (necessary to implement e.g. a loading - * bar). The callback receives an {Object} with the properties `loaded` - * ({number}) and `total` ({number}) that indicate how many bytes are loaded. + * bar). The callback receives an {@link OnProgressParameters} argument. * @property {function} [onUnsupportedFeature] - Callback for when an * unsupported feature is used in the PDF document. The callback receives an * {@link UNSUPPORTED_FEATURES} argument. @@ -581,9 +586,8 @@ const PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() { /** * Callback to be able to monitor the loading progress of the PDF file - * (necessary to implement e.g. a loading bar). The callback receives - * an {Object} with the properties `loaded` ({number}) and `total` - * ({number}) that indicate how many bytes are loaded. + * (necessary to implement e.g. a loading bar). + * The callback receives an {@link OnProgressParameters} argument. * @type {function} */ this.onProgress = null;