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

Function withoutLongRuns

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

Source from the content-addressed store, hash-verified

82 * Returns `text` itself when it has no such run.
83 */
84export function withoutLongRuns(text: string): string {
85 let parts: string[] | null = null;
86 let copied = 0;
87 let start = -1;
88 for (let i = 0; i <= text.length; i++) {
89 const code = i < text.length ? text.charCodeAt(i) : 0;
90 if (code < 128 && IN_NAME_RUN[code] === 1) {
91 if (start < 0) start = i;
92 continue;
93 }
94 if (start >= 0) {
95 if (i - start > LONGEST_NAME_RUN) {
96 (parts ??= []).push(text.slice(copied, start), RUN_FILL.repeat(i - start));
97 copied = i;
98 }
99 start = -1;
100 }
101 }
102 if (!parts) return text;
103 parts.push(text.slice(copied));
104 return parts.join('');
105}
106
107/** A source file's stats, and its bytes when they are within the limit (null = oversize). */
108export 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