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

Function stringEnd

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

The quote closing the string opened at `start`, or -1 when the string doesn't close.

(src: string, start: number)

Source from the content-addressed store, hash-verified

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 {
99 const quote = src.charCodeAt(start);
100 for (let k = start + 1; k < src.length; k++) {
101 const c = src.charCodeAt(k);
102 if (c === quote) return k;
103 if (c === 92) k += src.charCodeAt(k + 1) === 13 && src.charCodeAt(k + 2) === 10 ? 2 : 1;
104 else if (c === 10 || c === 13) return -1;
105 }
106 return -1;
107}
108
109/** `src` with the ranges (start and end pairs, in order) turned to spaces, line breaks kept. */
110function blankRanges(src: string, blanks: number[]): string {

Callers 1

codeMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected