From 704514c7cd3a216f02ee8708c63a470d60e1002a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 27 Apr 2021 13:07:39 +0200 Subject: [PATCH] Convert `src/core/run_length_stream.js` to use standard classes --- src/core/run_length_stream.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/core/run_length_stream.js b/src/core/run_length_stream.js index 8378f3179..c32d3fcf5 100644 --- a/src/core/run_length_stream.js +++ b/src/core/run_length_stream.js @@ -15,18 +15,15 @@ import { DecodeStream } from "./stream.js"; -const RunLengthStream = (function RunLengthStreamClosure() { - // eslint-disable-next-line no-shadow - function RunLengthStream(str, maybeLength) { +class RunLengthStream extends DecodeStream { + constructor(str, maybeLength) { + super(maybeLength); + this.str = str; this.dict = str.dict; - - DecodeStream.call(this, maybeLength); } - RunLengthStream.prototype = Object.create(DecodeStream.prototype); - - RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() { + readBlock() { // The repeatHeader has following format. The first byte defines type of run // and amount of bytes to repeat/copy: n = 0 through 127 - copy next n bytes // (in addition to the second byte from the header), n = 129 through 255 - @@ -58,9 +55,7 @@ const RunLengthStream = (function RunLengthStreamClosure() { } } this.bufferLength = bufferLength; - }; - - return RunLengthStream; -})(); + } +} export { RunLengthStream };