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:
		
							parent
							
								
									f90f9466e3
								
							
						
					
					
						commit
						45ddb12f61
					
				| @ -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); | ||||||
|  | |||||||
| @ -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( | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user