1 line
364 KiB
Text
1 line
364 KiB
Text
|
{"version":3,"file":"index.mjs.map","sources":["src/util.ts","src/reader.ts","src/regexp-syntax-error.ts","src/unicode/ids.ts","src/unicode/property-data.ts","src/unicode/index.ts","src/validator.ts","src/parser.ts","src/index.ts"],"sourcesContent":["export function assert(condition: boolean, message?: string): void {\n if (!condition) {\n throw new Error(message || \"AssertionError\")\n }\n}\n\nexport function last<T>(xs: T[]): T | undefined {\n return xs.length === 0 ? undefined : xs[xs.length - 1]\n}\n","const legacyImpl = {\n at(s: string, end: number, i: number): number {\n return i < end ? s.charCodeAt(i) : -1\n },\n width(c: number): number {\n return 1\n },\n}\nconst unicodeImpl = {\n at(s: string, end: number, i: number): number {\n return i < end ? s.codePointAt(i)! : -1\n },\n width(c: number): number {\n return c > 0xffff ? 2 : 1\n },\n}\n\nexport class Reader {\n private _impl = legacyImpl\n private _s: string = \"\"\n private _i: number = 0\n private _end: number = 0\n private _cp1: number = -1\n private _w1: number = 1\n private _cp2: number = -1\n private _w2: number = 1\n private _cp3: number = -1\n private _w3: number = 1\n private _cp4: number = -1\n\n get source(): string {\n return this._s\n }\n\n get index(): number {\n return this._i\n }\n\n get currentCodePoint(): number {\n return this._cp1\n }\n\n get nextCodePoint(): number {\n return this._cp2\n }\n\n get nextCodePoint2(): number {\n return this._cp3\n }\n\n get nextCodePoint3(): number {\n return this._cp4\n }\n\n reset(source: string, start: number, end: number, uFlag: boolean): void {\n this._impl = uFlag ? unicodeImpl : legacyImpl\n this._s = source\n this._end = end\n this.rewind(start)\n }\n\n rewind(index: number): void {\n const impl = this._impl\n this._i = index\n this._cp1 = impl.at(this._s, this._end, index)\n this._w1 = impl.width(this._cp1)\n this._cp2 = impl.at(this._s, this._end, index + this._w1)\n this._w2 = impl.width(this._cp2)\n this._cp3 = impl.at(this._s, this._end, index + this._w1 + this._w2)\n this._w3 = impl.width(this._cp3)\n this._cp4 = impl.at(\n this._s,\n this._end,\n index + this._w1 + this._w2 + this._w3,\n )\n }\n\n advance(): void {\n if (this._cp1 !== -1) {\n const impl = this._impl\n this._i += this._w1\n this._cp1 = this._cp2\n this._w1 = this._w2\n this._cp2 = this._cp3\n this._w2 = impl.width(this._cp2)\n this._cp3 = this._cp4\n this._w3 = impl.width(this._cp3)\n this._cp4 = impl.at(\n this._s,\n this._end,\n this._i + this._w1 + this._w2 + this._w3,\n )\n }\n }\n\n eat(cp: number): boolean {\n if (this._cp1 === cp) {\n this.advance()\n return true\n }\n return false\n }\n\n eat2(cp1: number, cp2: number): boolean {\n if (this._cp1 === cp1 && this._cp2 === cp2) {\n this.advance()\n this.advance()\n return true\n }\n return false\n }\n\n eat3(cp1: number, cp2: number, cp3: number): boolean {\n if (this._cp1 === cp1 && this._cp2 === cp2 && this._cp3 === cp3) {\n this.advance()\n this.advance()\n this.advance()\n return true\n }\n return false\n }\n}\n","export class RegExpSyntaxError extends SyntaxError {\n public index: number\n constructor(\n source: string,\n uFlag: boolean,\n index: number,\n message: string,\n ) {\n /*eslint-disable no-param-reassign */\n if (source) {\n if (source[0] !== \"/\") {\n source = `/${source}/${uFlag ? \"u\" : \"\"}`\n }\
|