Skip to content

Commit

Permalink
Drop buffer support, as this parser is always used on modified strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
lapo-luchini committed Sep 16, 2023
1 parent bfbf9ed commit 3585e31
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions parseRFC.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand All @@ -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();
Expand Down

0 comments on commit 3585e31

Please sign in to comment.