Convert src/core/decrypt_stream.js
to use standard classes
This commit is contained in:
parent
a9476e7dd0
commit
e938c05edb
@ -15,23 +15,20 @@
|
|||||||
|
|
||||||
import { DecodeStream } from "./stream.js";
|
import { DecodeStream } from "./stream.js";
|
||||||
|
|
||||||
const DecryptStream = (function DecryptStreamClosure() {
|
const chunkSize = 512;
|
||||||
// eslint-disable-next-line no-shadow
|
|
||||||
function DecryptStream(str, maybeLength, decrypt) {
|
class DecryptStream extends DecodeStream {
|
||||||
|
constructor(str, maybeLength, decrypt) {
|
||||||
|
super(maybeLength);
|
||||||
|
|
||||||
this.str = str;
|
this.str = str;
|
||||||
this.dict = str.dict;
|
this.dict = str.dict;
|
||||||
this.decrypt = decrypt;
|
this.decrypt = decrypt;
|
||||||
this.nextChunk = null;
|
this.nextChunk = null;
|
||||||
this.initialized = false;
|
this.initialized = false;
|
||||||
|
|
||||||
DecodeStream.call(this, maybeLength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const chunkSize = 512;
|
readBlock() {
|
||||||
|
|
||||||
DecryptStream.prototype = Object.create(DecodeStream.prototype);
|
|
||||||
|
|
||||||
DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
|
|
||||||
let chunk;
|
let chunk;
|
||||||
if (this.initialized) {
|
if (this.initialized) {
|
||||||
chunk = this.nextChunk;
|
chunk = this.nextChunk;
|
||||||
@ -56,9 +53,7 @@ const DecryptStream = (function DecryptStreamClosure() {
|
|||||||
buffer[bufferLength++] = chunk[i];
|
buffer[bufferLength++] = chunk[i];
|
||||||
}
|
}
|
||||||
this.bufferLength = bufferLength;
|
this.bufferLength = bufferLength;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
return DecryptStream;
|
|
||||||
})();
|
|
||||||
|
|
||||||
export { DecryptStream };
|
export { DecryptStream };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user