From 45ddb12f61ca302ad892b8e70424c97cec171cb2 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 6 Sep 2021 11:19:12 +0200 Subject: [PATCH] Remove no-op `onPull`/`onCancel` streamSink callbacks from the "GetTextContent"-handler The `MessageHandler`-implementation already handles either of these callbacks being undefined, hence there's no particular reason (as far as I can tell) to add no-op functions here. Also, in a couple of `MessageHandler`-methods, utilize an already existing local variable more. --- src/core/worker.js | 2 -- src/shared/message_handler.js | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/worker.js b/src/core/worker.js index 023d5307c..9ae394881 100644 --- a/src/core/worker.js +++ b/src/core/worker.js @@ -737,8 +737,6 @@ class WorkerMessageHandler { handler.on("GetTextContent", function wphExtractText(data, sink) { const pageIndex = data.pageIndex; - sink.onPull = function (desiredSize) {}; - sink.onCancel = function (reason) {}; pdfManager.getPage(pageIndex).then(function (page) { const task = new WorkerTask("GetTextContent: page " + pageIndex); diff --git a/src/shared/message_handler.js b/src/shared/message_handler.js index bf4e81f8d..add84305b 100644 --- a/src/shared/message_handler.js +++ b/src/shared/message_handler.js @@ -448,7 +448,7 @@ class MessageHandler { } // Reset desiredSize property of sink on every pull. this.streamSinks[streamId].desiredSize = data.desiredSize; - const { onPull } = this.streamSinks[data.streamId]; + const { onPull } = this.streamSinks[streamId]; new Promise(function (resolve) { resolve(onPull && onPull()); }).then( @@ -518,7 +518,7 @@ class MessageHandler { if (!this.streamSinks[streamId]) { break; } - const { onCancel } = this.streamSinks[data.streamId]; + const { onCancel } = this.streamSinks[streamId]; new Promise(function (resolve) { resolve(onCancel && onCancel(wrapReason(data.reason))); }).then(