MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / regexEnd

Function regexEnd

src/resolution/jsx-code.ts:82–95  ·  view source on GitHub ↗

The `/` closing the regex literal opened at `start`, or -1 when it doesn't close on its line.

(src: string, start: number)

Source from the content-addressed store, hash-verified

80
81/** The `/` closing the regex literal opened at `start`, or -1 when it doesn't close on its line. */
82function regexEnd(src: string, start: number): number {
83 let inClass = false;
84 for (let k = start + 1; k < src.length; k++) {
85 const c = src.charCodeAt(k);
86 if (c === 10 || c === 13) return -1;
87 if (c === 92) {
88 k++;
89 if (src.charCodeAt(k) === 10 || src.charCodeAt(k) === 13) return -1;
90 } else if (c === 91) inClass = true;
91 else if (c === 93) inClass = false;
92 else if (c === 47 && !inClass) return k;
93 }
94 return -1;
95}
96
97/** The quote closing the string opened at `start`, or -1 when the string doesn't close. */
98function stringEnd(src: string, start: number): number {

Callers 1

codeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected