@@ -413,34 +413,34 @@ function getDocument(src = {}) {
413
413
} ) ;
414
414
} else if ( ! data ) {
415
415
if ( typeof PDFJSDev !== "undefined" && PDFJSDev . test ( "MOZCENTRAL" ) ) {
416
- throw new Error ( "Not implemented: createPDFNetworkStream " ) ;
416
+ throw new Error ( "Not implemented: NetworkStream " ) ;
417
417
}
418
418
if ( ! url ) {
419
419
throw new Error ( "getDocument - no `url` parameter provided." ) ;
420
420
}
421
- const createPDFNetworkStream = params => {
422
- if (
423
- typeof PDFJSDev !== "undefined" &&
424
- PDFJSDev . test ( "GENERIC" ) &&
425
- isNodeJS
426
- ) {
427
- const isFetchSupported = function ( ) {
428
- return (
429
- typeof fetch !== "undefined" &&
430
- typeof Response !== "undefined" &&
431
- "body" in Response . prototype
432
- ) ;
433
- } ;
434
- return isFetchSupported ( ) && isValidFetchUrl ( params . url )
435
- ? new PDFFetchStream ( params )
436
- : new PDFNodeStream ( params ) ;
437
- }
438
- return isValidFetchUrl ( params . url )
439
- ? new PDFFetchStream ( params )
440
- : new PDFNetworkStream ( params ) ;
441
- } ;
421
+ let NetworkStream ;
422
+
423
+ if (
424
+ typeof PDFJSDev !== "undefined" &&
425
+ PDFJSDev . test ( "GENERIC" ) &&
426
+ isNodeJS
427
+ ) {
428
+ const isFetchSupported =
429
+ typeof fetch !== "undefined" &&
430
+ typeof Response !== "undefined" &&
431
+ "body" in Response . prototype ;
432
+
433
+ NetworkStream =
434
+ isFetchSupported && isValidFetchUrl ( url )
435
+ ? PDFFetchStream
436
+ : PDFNodeStream ;
437
+ } else {
438
+ NetworkStream = isValidFetchUrl ( url )
439
+ ? PDFFetchStream
440
+ : PDFNetworkStream ;
441
+ }
442
442
443
- networkStream = createPDFNetworkStream ( {
443
+ networkStream = new NetworkStream ( {
444
444
url,
445
445
length,
446
446
httpHeaders,
0 commit comments