Convert src/core/ascii_85_stream.js
to use standard classes
This commit is contained in:
parent
f6c7a65202
commit
cdb583b764
@ -16,24 +16,21 @@
|
|||||||
import { DecodeStream } from "./stream.js";
|
import { DecodeStream } from "./stream.js";
|
||||||
import { isWhiteSpace } from "./core_utils.js";
|
import { isWhiteSpace } from "./core_utils.js";
|
||||||
|
|
||||||
const Ascii85Stream = (function Ascii85StreamClosure() {
|
class Ascii85Stream extends DecodeStream {
|
||||||
// eslint-disable-next-line no-shadow
|
constructor(str, maybeLength) {
|
||||||
function Ascii85Stream(str, maybeLength) {
|
|
||||||
this.str = str;
|
|
||||||
this.dict = str.dict;
|
|
||||||
this.input = new Uint8Array(5);
|
|
||||||
|
|
||||||
// Most streams increase in size when decoded, but Ascii85 streams
|
// Most streams increase in size when decoded, but Ascii85 streams
|
||||||
// typically shrink by ~20%.
|
// typically shrink by ~20%.
|
||||||
if (maybeLength) {
|
if (maybeLength) {
|
||||||
maybeLength = 0.8 * maybeLength;
|
maybeLength = 0.8 * maybeLength;
|
||||||
}
|
}
|
||||||
DecodeStream.call(this, maybeLength);
|
super(maybeLength);
|
||||||
|
|
||||||
|
this.str = str;
|
||||||
|
this.dict = str.dict;
|
||||||
|
this.input = new Uint8Array(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
|
readBlock() {
|
||||||
|
|
||||||
Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
|
|
||||||
const TILDA_CHAR = 0x7e; // '~'
|
const TILDA_CHAR = 0x7e; // '~'
|
||||||
const Z_LOWER_CHAR = 0x7a; // 'z'
|
const Z_LOWER_CHAR = 0x7a; // 'z'
|
||||||
const EOF = -1;
|
const EOF = -1;
|
||||||
@ -95,9 +92,7 @@ const Ascii85Stream = (function Ascii85StreamClosure() {
|
|||||||
t >>= 8;
|
t >>= 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
return Ascii85Stream;
|
|
||||||
})();
|
|
||||||
|
|
||||||
export { Ascii85Stream };
|
export { Ascii85Stream };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user