UNPKG

tell-me-when

Version:
38 lines 851 B
export class ParseState { index = 0; start; end; flags; constructor(input, { start = 0, end = input.length, flags = 'g' } = {}) { this.input = input; this.start = start; this.end = end; this.flags = flags; } get done() { return this.index >= this.end; } testLowerCase(pattern) { if (this.input.substring(this.index, this.index + pattern.length).toLowerCase() === pattern) { this.index += pattern.length; return true; } return false; } testRegex(pattern) { pattern.lastIndex = this.index; if (pattern.test(this.input)) { this.index = pattern.lastIndex; return true; } return false; } } export function toRegExp(s, flags = '') { return new RegExp(s.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&'), flags); } //# sourceMappingURL=ParseState.mjs.map