Convert src/core/jbig2_stream.js
to use standard classes
This commit is contained in:
parent
d9c1bf96b6
commit
c51ef1f21f
@ -22,33 +22,27 @@ import { shadow } from "../shared/util.js";
|
|||||||
* For JBIG2's we use a library to decode these images and
|
* For JBIG2's we use a library to decode these images and
|
||||||
* the stream behaves like all the other DecodeStreams.
|
* the stream behaves like all the other DecodeStreams.
|
||||||
*/
|
*/
|
||||||
const Jbig2Stream = (function Jbig2StreamClosure() {
|
class Jbig2Stream extends DecodeStream {
|
||||||
// eslint-disable-next-line no-shadow
|
constructor(stream, maybeLength, dict, params) {
|
||||||
function Jbig2Stream(stream, maybeLength, dict, params) {
|
super(maybeLength);
|
||||||
|
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
this.maybeLength = maybeLength;
|
this.maybeLength = maybeLength;
|
||||||
this.dict = dict;
|
this.dict = dict;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
|
|
||||||
DecodeStream.call(this, maybeLength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
|
get bytes() {
|
||||||
|
// If `this.maybeLength` is null, we'll get the entire stream.
|
||||||
|
return shadow(this, "bytes", this.stream.getBytes(this.maybeLength));
|
||||||
|
}
|
||||||
|
|
||||||
Object.defineProperty(Jbig2Stream.prototype, "bytes", {
|
ensureBuffer(requested) {
|
||||||
get() {
|
|
||||||
// If `this.maybeLength` is null, we'll get the entire stream.
|
|
||||||
return shadow(this, "bytes", this.stream.getBytes(this.maybeLength));
|
|
||||||
},
|
|
||||||
configurable: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
Jbig2Stream.prototype.ensureBuffer = function (requested) {
|
|
||||||
// No-op, since `this.readBlock` will always parse the entire image and
|
// No-op, since `this.readBlock` will always parse the entire image and
|
||||||
// directly insert all of its data into `this.buffer`.
|
// directly insert all of its data into `this.buffer`.
|
||||||
};
|
}
|
||||||
|
|
||||||
Jbig2Stream.prototype.readBlock = function () {
|
readBlock() {
|
||||||
if (this.eof) {
|
if (this.eof) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -73,9 +67,7 @@ const Jbig2Stream = (function Jbig2StreamClosure() {
|
|||||||
this.buffer = data;
|
this.buffer = data;
|
||||||
this.bufferLength = dataLength;
|
this.bufferLength = dataLength;
|
||||||
this.eof = true;
|
this.eof = true;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
return Jbig2Stream;
|
|
||||||
})();
|
|
||||||
|
|
||||||
export { Jbig2Stream };
|
export { Jbig2Stream };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user