From 3585e314cdbad7b63e5b41d11d7eb4a4d2f9761b Mon Sep 17 00:00:00 2001 From: Lapo Luchini Date: Sat, 16 Sep 2023 11:28:10 +0000 Subject: [PATCH] Drop buffer support, as this parser is always used on modified strings. --- parseRFC.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parseRFC.js b/parseRFC.js index 7db0259..84e735d 100755 --- a/parseRFC.js +++ b/parseRFC.js @@ -83,8 +83,8 @@ class Parser { throw 'Requesting byte offset ' + pos + ' on a stream of length ' + this.enc.length; return this.enc.charAt(pos); } - exception(s, pos) { - if (pos == undefined) pos = this.pos; + exception(s) { + const pos = this.pos; let from = Math.max(pos - 30, this.start); let to = Math.min(pos + 30, this.enc.length); let ctx = ''; @@ -110,10 +110,10 @@ class Parser { throw new Error('[position ' + pos + ', line ' + line + ':' + column + '] ' + s + '\n' + ctx.replace(/\s/g, ' ') + '\n' + arrow); } peek() { - return (typeof this.enc == 'string') ? this.enc.charCodeAt(this.pos) : this.enc[this.pos]; + return this.enc.charCodeAt(this.pos); } peekChar() { - return (typeof this.enc == 'string') ? this.enc.charAt(this.pos) : String.fromCharCode(this.enc[this.pos]); + return this.enc.charAt(this.pos); } isWhitespace() { let c = this.peekChar(); -- 2.51.2