Use more optional chaining in the code-base (PR 15398 follow-up)
*Fixes a few cases that I missed in PR 15398.*
This commit is contained in:
parent
2146d93609
commit
9f637966f8
@ -190,12 +190,11 @@ class PDFFetchStreamReader {
|
|||||||
return { value, done };
|
return { value, done };
|
||||||
}
|
}
|
||||||
this._loaded += value.byteLength;
|
this._loaded += value.byteLength;
|
||||||
if (this.onProgress) {
|
this.onProgress?.({
|
||||||
this.onProgress({
|
loaded: this._loaded,
|
||||||
loaded: this._loaded,
|
total: this._contentLength,
|
||||||
total: this._contentLength,
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
const buffer = new Uint8Array(value).buffer;
|
const buffer = new Uint8Array(value).buffer;
|
||||||
return { value: buffer, done: false };
|
return { value: buffer, done: false };
|
||||||
}
|
}
|
||||||
|
@ -163,12 +163,11 @@ class BaseFullReader {
|
|||||||
return this.read();
|
return this.read();
|
||||||
}
|
}
|
||||||
this._loaded += chunk.length;
|
this._loaded += chunk.length;
|
||||||
if (this.onProgress) {
|
this.onProgress?.({
|
||||||
this.onProgress({
|
loaded: this._loaded,
|
||||||
loaded: this._loaded,
|
total: this._contentLength,
|
||||||
total: this._contentLength,
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
// Ensure that `read()` method returns ArrayBuffer.
|
// Ensure that `read()` method returns ArrayBuffer.
|
||||||
const buffer = new Uint8Array(chunk).buffer;
|
const buffer = new Uint8Array(chunk).buffer;
|
||||||
return { value: buffer, done: false };
|
return { value: buffer, done: false };
|
||||||
|
@ -92,15 +92,12 @@ class PDFDataTransportStream {
|
|||||||
_onProgress(evt) {
|
_onProgress(evt) {
|
||||||
if (evt.total === undefined) {
|
if (evt.total === undefined) {
|
||||||
// Reporting to first range reader, if it exists.
|
// Reporting to first range reader, if it exists.
|
||||||
const firstReader = this._rangeReaders[0];
|
this._rangeReaders[0]?.onProgress?.({ loaded: evt.loaded });
|
||||||
if (firstReader?.onProgress) {
|
|
||||||
firstReader.onProgress({ loaded: evt.loaded });
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const fullReader = this._fullRequestReader;
|
this._fullRequestReader?.onProgress?.({
|
||||||
if (fullReader?.onProgress) {
|
loaded: evt.loaded,
|
||||||
fullReader.onProgress({ loaded: evt.loaded, total: evt.total });
|
total: evt.total,
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user