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

Function withoutLongRuns

src/file-limits.ts:132–153  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

130 * Returns `text` itself when it has no such run.
131 */
132export function withoutLongRuns(text: string): string {
133 let parts: string[] | null = null;
134 let copied = 0;
135 let start = -1;
136 for (let i = 0; i <= text.length; i++) {
137 const code = i < text.length ? text.charCodeAt(i) : 0;
138 if (code < 128 && IN_NAME_RUN[code] === 1) {
139 if (start < 0) start = i;
140 continue;
141 }
142 if (start >= 0) {
143 if (i - start > LONGEST_NAME_RUN) {
144 (parts ??= []).push(text.slice(copied, start), RUN_FILL.repeat(i - start));
145 copied = i;
146 }
147 start = -1;
148 }
149 }
150 if (!parts) return text;
151 parts.push(text.slice(copied));
152 return parts.join('');
153}
154
155/** A source file's stats, and its bytes when they are within the limit (null = oversize). */
156export interface BoundedSource {

Callers 4

readFileCachedMethod · 0.90
scanFileMethod · 0.90
hasSynthesisPatternFunction · 0.90

Calls 2

pushMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected