From 0ca63f94b495034a1ca9a2aa5b69d3273cc90afd Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 27 Apr 2021 12:27:36 +0200 Subject: [PATCH] Convert `src/core/ccitt_stream.js` to use standard classes --- src/core/ccitt_stream.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/core/ccitt_stream.js b/src/core/ccitt_stream.js index ced509334..6f597689a 100644 --- a/src/core/ccitt_stream.js +++ b/src/core/ccitt_stream.js @@ -17,9 +17,10 @@ import { Dict, isDict } from "./primitives.js"; import { CCITTFaxDecoder } from "./ccitt.js"; import { DecodeStream } from "./stream.js"; -const CCITTFaxStream = (function CCITTFaxStreamClosure() { - // eslint-disable-next-line no-shadow - function CCITTFaxStream(str, maybeLength, params) { +class CCITTFaxStream extends DecodeStream { + constructor(str, maybeLength, params) { + super(maybeLength); + this.str = str; this.dict = str.dict; @@ -41,13 +42,9 @@ const CCITTFaxStream = (function CCITTFaxStreamClosure() { EndOfBlock: params.get("EndOfBlock"), BlackIs1: params.get("BlackIs1"), }); - - DecodeStream.call(this, maybeLength); } - CCITTFaxStream.prototype = Object.create(DecodeStream.prototype); - - CCITTFaxStream.prototype.readBlock = function () { + readBlock() { while (!this.eof) { const c = this.ccittFaxDecoder.readNextChar(); if (c === -1) { @@ -57,9 +54,7 @@ const CCITTFaxStream = (function CCITTFaxStreamClosure() { this.ensureBuffer(this.bufferLength + 1); this.buffer[this.bufferLength++] = c; } - }; - - return CCITTFaxStream; -})(); + } +} export { CCITTFaxStream };