Skip to content

Commit 9872657

Browse files
committed
Remove the unused IPDFStreamRangeReader.prototype.isStreamingSupported getter
This getter was only invoked from `src/display/network.js` and `src/core/chunked_stream.js`, however in both cases it's hardcoded to `false` and thus isn't actually needed. This originated in PR 6879, close to a decade ago, for a potential TODO which was never implemented and it ought to be OK to just simplify this now.
1 parent 62d5408 commit 9872657

File tree

7 files changed

+4
-47
lines changed

7 files changed

+4
-47
lines changed

src/core/chunked_stream.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -283,19 +283,15 @@ class ChunkedStreamManager {
283283

284284
sendRequest(begin, end) {
285285
const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
286-
if (!rangeReader.isStreamingSupported) {
287-
rangeReader.onProgress = this.onProgress.bind(this);
288-
}
286+
rangeReader.onProgress = this.onProgress.bind(this);
289287

290-
let chunks = [],
291-
loaded = 0;
288+
let chunks = [];
292289
return new Promise((resolve, reject) => {
293290
const readChunk = ({ value, done }) => {
294291
try {
295292
if (done) {
296-
const chunkData = arrayBuffersToBytes(chunks);
293+
resolve(arrayBuffersToBytes(chunks));
297294
chunks = null;
298-
resolve(chunkData);
299295
return;
300296
}
301297
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
@@ -304,12 +300,6 @@ class ChunkedStreamManager {
304300
"readChunk (sendRequest) - expected an ArrayBuffer."
305301
);
306302
}
307-
loaded += value.byteLength;
308-
309-
if (rangeReader.isStreamingSupported) {
310-
this.onProgress({ loaded });
311-
}
312-
313303
chunks.push(value);
314304
rangeReader.read().then(readChunk, reject);
315305
} catch (e) {

src/core/worker_stream.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ class PDFWorkerStreamRangeReader {
114114
this._reader = readableStream.getReader();
115115
}
116116

117-
get isStreamingSupported() {
118-
return false;
119-
}
120-
121117
async read() {
122118
const { value, done } = await this._reader.read();
123119
if (done) {

src/display/fetch_stream.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ class PDFFetchStreamRangeReader {
209209
const source = stream.source;
210210
this._withCredentials = source.withCredentials || false;
211211
this._readCapability = Promise.withResolvers();
212-
this._isStreamingSupported = !source.disableStream;
213212

214213
this._abortController = new AbortController();
215214
// Always create a copy of the headers.
@@ -240,10 +239,6 @@ class PDFFetchStreamRangeReader {
240239
this.onProgress = null;
241240
}
242241

243-
get isStreamingSupported() {
244-
return this._isStreamingSupported;
245-
}
246-
247242
async read() {
248243
await this._readCapability.promise;
249244
const { value, done } = await this._reader.read();

src/display/network.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,7 @@ class PDFNetworkStreamRangeRequestReader {
413413
}
414414

415415
_onProgress(evt) {
416-
if (!this.isStreamingSupported) {
417-
this.onProgress?.({ loaded: evt.loaded });
418-
}
419-
}
420-
421-
get isStreamingSupported() {
422-
return false;
416+
this.onProgress?.({ loaded: evt.loaded });
423417
}
424418

425419
async read() {

src/display/node_stream.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ class PDFNodeStreamFsRangeReader {
208208
constructor(stream, begin, end) {
209209
this.onProgress = null;
210210
this._loaded = 0;
211-
const source = stream.source;
212-
this._isStreamingSupported = !source.disableStream;
213211

214212
const url = stream.url;
215213
const fs = process.getBuiltinModule("fs");
@@ -228,10 +226,6 @@ class PDFNodeStreamFsRangeReader {
228226
}
229227
}
230228

231-
get isStreamingSupported() {
232-
return this._isStreamingSupported;
233-
}
234-
235229
async read() {
236230
await this._readCapability.promise;
237231
const { value, done } = await this._reader.read();

src/display/transport_stream.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,6 @@ class PDFDataTransportStreamRangeReader {
287287
this._stream._removeRangeReader(this);
288288
}
289289

290-
get isStreamingSupported() {
291-
return false;
292-
}
293-
294290
async read() {
295291
if (this._queuedChunk) {
296292
const chunk = this._queuedChunk;

src/interfaces.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,6 @@ class IPDFStreamRangeReader {
145145
this.onProgress = null;
146146
}
147147

148-
/**
149-
* Gets ability of the stream to progressively load binary data.
150-
* @type {boolean}
151-
*/
152-
get isStreamingSupported() {
153-
return false;
154-
}
155-
156148
/**
157149
* Requests a chunk of the binary data. The method returns the promise, which
158150
* is resolved into object with properties "value" and "done". If the done

0 commit comments

Comments
 (0)