Add more validation in PDFWorker.fromPort
The signature of the `PDFWorker.fromPort` method, in addition to the `PDFWorker` constructor, was changed in PR 9480. Hence it's probably a good idea to add a bit more validation to `PDFWorker.fromPort`, to ensure that it won't fail silently for an API consumer that updates to version 2.0 of the PDF.js library.
This commit is contained in:
parent
3c5c8d2a0b
commit
47a9d38280
@ -1593,6 +1593,9 @@ var PDFWorker = (function PDFWorkerClosure() {
|
||||
* @param {PDFWorkerParameters} params - The worker initialization parameters.
|
||||
*/
|
||||
PDFWorker.fromPort = function(params) {
|
||||
if (!params || !params.port) {
|
||||
throw new Error('PDFWorker.fromPort - invalid method signature.');
|
||||
}
|
||||
if (pdfWorkerPorts.has(params.port)) {
|
||||
return pdfWorkerPorts.get(params.port);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user