mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Change the createPromiseCapability
helper function into a PromiseCapability
class
This is not only slightly more compact, but it also simplifies the handling of the `settled` getter.
This commit is contained in:
parent
f9c2a8d437
commit
317abd6d07
24 changed files with 117 additions and 122 deletions
|
@ -17,8 +17,8 @@
|
|||
import {
|
||||
AbortException,
|
||||
assert,
|
||||
createPromiseCapability,
|
||||
MissingPDFException,
|
||||
PromiseCapability,
|
||||
} from "../shared/util.js";
|
||||
import {
|
||||
extractFilenameFromHeader,
|
||||
|
@ -124,8 +124,8 @@ class BaseFullReader {
|
|||
this._isRangeSupported = !source.disableRange;
|
||||
|
||||
this._readableStream = null;
|
||||
this._readCapability = createPromiseCapability();
|
||||
this._headersCapability = createPromiseCapability();
|
||||
this._readCapability = new PromiseCapability();
|
||||
this._headersCapability = new PromiseCapability();
|
||||
}
|
||||
|
||||
get headersReady() {
|
||||
|
@ -159,7 +159,7 @@ class BaseFullReader {
|
|||
|
||||
const chunk = this._readableStream.read();
|
||||
if (chunk === null) {
|
||||
this._readCapability = createPromiseCapability();
|
||||
this._readCapability = new PromiseCapability();
|
||||
return this.read();
|
||||
}
|
||||
this._loaded += chunk.length;
|
||||
|
@ -226,7 +226,7 @@ class BaseRangeReader {
|
|||
this.onProgress = null;
|
||||
this._loaded = 0;
|
||||
this._readableStream = null;
|
||||
this._readCapability = createPromiseCapability();
|
||||
this._readCapability = new PromiseCapability();
|
||||
const source = stream.source;
|
||||
this._isStreamingSupported = !source.disableStream;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ class BaseRangeReader {
|
|||
|
||||
const chunk = this._readableStream.read();
|
||||
if (chunk === null) {
|
||||
this._readCapability = createPromiseCapability();
|
||||
this._readCapability = new PromiseCapability();
|
||||
return this.read();
|
||||
}
|
||||
this._loaded += chunk.length;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue