From cdb583b7644d8fec9c0b12afb37a7de4f52faed8 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 27 Apr 2021 13:26:42 +0200 Subject: [PATCH] Convert `src/core/ascii_85_stream.js` to use standard classes --- src/core/ascii_85_stream.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/core/ascii_85_stream.js b/src/core/ascii_85_stream.js index 9b27cfd57..159eae66e 100644 --- a/src/core/ascii_85_stream.js +++ b/src/core/ascii_85_stream.js @@ -16,24 +16,21 @@ import { DecodeStream } from "./stream.js"; import { isWhiteSpace } from "./core_utils.js"; -const Ascii85Stream = (function Ascii85StreamClosure() { - // eslint-disable-next-line no-shadow - function Ascii85Stream(str, maybeLength) { - this.str = str; - this.dict = str.dict; - this.input = new Uint8Array(5); - +class Ascii85Stream extends DecodeStream { + constructor(str, maybeLength) { // Most streams increase in size when decoded, but Ascii85 streams // typically shrink by ~20%. if (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); - - Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() { + readBlock() { const TILDA_CHAR = 0x7e; // '~' const Z_LOWER_CHAR = 0x7a; // 'z' const EOF = -1; @@ -95,9 +92,7 @@ const Ascii85Stream = (function Ascii85StreamClosure() { t >>= 8; } } - }; - - return Ascii85Stream; -})(); + } +} export { Ascii85Stream };