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

Function blankRanges

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

`src` with the ranges (start and end pairs, in order) turned to spaces, line breaks kept.

(src: string, blanks: number[])

Source from the content-addressed store, hash-verified

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 {
111 if (blanks.length === 0) return src;
112 const parts: string[] = [];
113 let from = 0;
114 for (let b = 0; b < blanks.length; b += 2) {
115 const start = blanks[b]!;
116 const end = blanks[b + 1]!;
117 if (start < from) continue;
118 parts.push(src.slice(from, start));
119 const text = src.slice(start, end);
120 parts.push(/[\r\n]/.test(text) ? text.replace(/[^\r\n]/g, ' ') : ' '.repeat(end - start));
121 from = end;
122 }
123 parts.push(src.slice(from));
124 return parts.join('');
125}
126
127export function jsxCode(src: string): string | null {
128 return new JsxLexer(src).read();

Callers 1

readMethod · 0.70

Calls 2

pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected