Remove "else after return" from the getUrlProp
/getDataProp
helper functions
This helps readability of this code a little bit, in my opinion, and it's actually ever so slightly less code in the *built* `pdf.js` file.
This commit is contained in:
parent
546902df63
commit
df3b359280
@ -507,7 +507,8 @@ async function _fetchDocument(worker, source) {
|
||||
function getUrlProp(val) {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
return null; // The 'url' is unused with `PDFDataRangeTransport`.
|
||||
} else if (val instanceof URL) {
|
||||
}
|
||||
if (val instanceof URL) {
|
||||
return val.href;
|
||||
}
|
||||
try {
|
||||
@ -539,20 +540,17 @@ function getDataProp(val) {
|
||||
val instanceof Buffer // eslint-disable-line no-undef
|
||||
) {
|
||||
return new Uint8Array(val);
|
||||
} else if (
|
||||
val instanceof Uint8Array &&
|
||||
val.byteLength === val.buffer.byteLength
|
||||
) {
|
||||
}
|
||||
if (val instanceof Uint8Array && val.byteLength === val.buffer.byteLength) {
|
||||
// Use the data as-is when it's already a Uint8Array that completely
|
||||
// "utilizes" its underlying ArrayBuffer, to prevent any possible
|
||||
// issues when transferring it to the worker-thread.
|
||||
return val;
|
||||
} else if (typeof val === "string") {
|
||||
}
|
||||
if (typeof val === "string") {
|
||||
return stringToBytes(val);
|
||||
} else if (
|
||||
(typeof val === "object" && !isNaN(val?.length)) ||
|
||||
isArrayBuffer(val)
|
||||
) {
|
||||
}
|
||||
if ((typeof val === "object" && !isNaN(val?.length)) || isArrayBuffer(val)) {
|
||||
return new Uint8Array(val);
|
||||
}
|
||||
throw new Error(
|
||||
|
Loading…
x
Reference in New Issue
Block a user