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

Function topLevelBars

src/resolution/frameworks/next-proxy.ts:201–220  ·  view source on GitHub ↗

`a|b|(c|d)` split at its top-level bars.

(s: string)

Source from the content-addressed store, hash-verified

199
200/** `a|b|(c|d)` split at its top-level bars. */
201function topLevelBars(s: string): string[] {
202 const out: string[] = [];
203 let from = 0;
204 for (let i = 0; i < s.length; i++) {
205 const c = s[i];
206 if (c === '\\') i++;
207 else if (c === '[') {
208 while (i < s.length && s[i] !== ']') i += s[i] === '\\' ? 2 : 1;
209 } else if (c === '(') {
210 const close = closingParen(s, i);
211 if (close < 0) return [s];
212 i = close;
213 } else if (c === '|') {
214 out.push(s.slice(from, i));
215 from = i + 1;
216 }
217 }
218 out.push(s.slice(from));
219 return out;
220}
221
222/**
223 * One branch of a negative lookahead, as a regex of our own: a literal path

Callers 1

readGroupFunction · 0.85

Calls 2

closingParenFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected