this.nodeTypes = nodeTypes this.inline = null this.pos = 0 this.tokens = string.split(/\s*(?=\b|\W|$)/) if (this.tokens[this.tokens.length - 1] == "") this.tokens.pop() if (this.tokens[0] == "") this.tokens.shift() } get next() { return this.tokens[this.pos] } eat(tok) { return this.next == tok && (this.pos++ || true) } err(str) { throw new SyntaxError(str + " (in content expression '" + this.string + "')") } } function parseExpr(stream) { let exprs = [] do { exprs.push(parseExprSeq(stream)) } while (stream.eat("|")) return exprs.length == 1 ? exprs[0] : {type: "choice", exprs} }
we can replace eat(tok) { return this.next == tok && (this.pos++ || true) }
with eat(tok) { return this.next == tok && (++this.pos) }
to save few bytes.
kepta
December 31, 2020, 7:42am
#2
in my humble opinion sending a pull request on Github might facilitate a better discussion for your proposed changes.