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.
This commit is contained in:
Jonas Jenwald 2021-09-06 11:19:12 +02:00
parent f90f9466e3
commit 45ddb12f61
2 changed files with 2 additions and 4 deletions

View File

@ -737,8 +737,6 @@ class WorkerMessageHandler {
handler.on("GetTextContent", function wphExtractText(data, sink) { handler.on("GetTextContent", function wphExtractText(data, sink) {
const pageIndex = data.pageIndex; const pageIndex = data.pageIndex;
sink.onPull = function (desiredSize) {};
sink.onCancel = function (reason) {};
pdfManager.getPage(pageIndex).then(function (page) { pdfManager.getPage(pageIndex).then(function (page) {
const task = new WorkerTask("GetTextContent: page " + pageIndex); const task = new WorkerTask("GetTextContent: page " + pageIndex);

View File

@ -448,7 +448,7 @@ class MessageHandler {
} }
// Reset desiredSize property of sink on every pull. // Reset desiredSize property of sink on every pull.
this.streamSinks[streamId].desiredSize = data.desiredSize; this.streamSinks[streamId].desiredSize = data.desiredSize;
const { onPull } = this.streamSinks[data.streamId]; const { onPull } = this.streamSinks[streamId];
new Promise(function (resolve) { new Promise(function (resolve) {
resolve(onPull && onPull()); resolve(onPull && onPull());
}).then( }).then(
@ -518,7 +518,7 @@ class MessageHandler {
if (!this.streamSinks[streamId]) { if (!this.streamSinks[streamId]) {
break; break;
} }
const { onCancel } = this.streamSinks[data.streamId]; const { onCancel } = this.streamSinks[streamId];
new Promise(function (resolve) { new Promise(function (resolve) {
resolve(onCancel && onCancel(wrapReason(data.reason))); resolve(onCancel && onCancel(wrapReason(data.reason)));
}).then( }).then(