Enable the no-var rule in the src/core/decrypt_stream.js file

This commit is contained in:
Jonas Jenwald 2021-04-27 13:34:42 +02:00
parent 28b0809e60
commit a9476e7dd0

View File

@ -12,11 +12,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-var */
import { DecodeStream } from "./stream.js"; import { DecodeStream } from "./stream.js";
var DecryptStream = (function DecryptStreamClosure() { const DecryptStream = (function DecryptStreamClosure() {
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
function DecryptStream(str, maybeLength, decrypt) { function DecryptStream(str, maybeLength, decrypt) {
this.str = str; this.str = str;
@ -28,12 +27,12 @@ var DecryptStream = (function DecryptStreamClosure() {
DecodeStream.call(this, maybeLength); DecodeStream.call(this, maybeLength);
} }
var chunkSize = 512; const chunkSize = 512;
DecryptStream.prototype = Object.create(DecodeStream.prototype); DecryptStream.prototype = Object.create(DecodeStream.prototype);
DecryptStream.prototype.readBlock = function DecryptStream_readBlock() { DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
var chunk; let chunk;
if (this.initialized) { if (this.initialized) {
chunk = this.nextChunk; chunk = this.nextChunk;
} else { } else {
@ -45,16 +44,15 @@ var DecryptStream = (function DecryptStreamClosure() {
return; return;
} }
this.nextChunk = this.str.getBytes(chunkSize); this.nextChunk = this.str.getBytes(chunkSize);
var hasMoreData = this.nextChunk && this.nextChunk.length > 0; const hasMoreData = this.nextChunk && this.nextChunk.length > 0;
var decrypt = this.decrypt; const decrypt = this.decrypt;
chunk = decrypt(chunk, !hasMoreData); chunk = decrypt(chunk, !hasMoreData);
var bufferLength = this.bufferLength; let bufferLength = this.bufferLength;
var i, const n = chunk.length,
n = chunk.length; buffer = this.ensureBuffer(bufferLength + n);
var buffer = this.ensureBuffer(bufferLength + n); for (let i = 0; i < n; i++) {
for (i = 0; i < n; i++) {
buffer[bufferLength++] = chunk[i]; buffer[bufferLength++] = chunk[i];
} }
this.bufferLength = bufferLength; this.bufferLength = bufferLength;