MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / arrayItems

Function arrayItems

graph-ui/src/browser-ai/file-outline.ts:46–58  ·  view source on GitHub ↗

The items of an array, split at its own commas, not at those inside strings or inline tables.

(inner: string)

Source from the content-addressed store, hash-verified

44}
45/** The items of an array, split at its own commas, not at those inside strings or inline tables. */
46function arrayItems(inner: string): string[] {
47 const items: string[] = [];
48 let depth = 0, quote: string | undefined, start = 0;
49 for (let index = 0; index < inner.length; index++) {
50 const character = inner[index];
51 if (quote) { if (character === '\\' && quote === '"') index++; else if (character === quote) quote = undefined; continue; }
52 if (character === '"' || character === "'") quote = character;
53 else if (character === '[' || character === '{') depth++;
54 else if (character === ']' || character === '}') depth--;
55 else if (character === ',' && depth === 0) { items.push(inner.slice(start, index)); start = index + 1; }
56 }
57 return [...items, inner.slice(start)].map(item => item.trim()).filter(Boolean);
58}
59
60/** TOML: the keys before the first table, each `[table]` with its keys, each `[[table]]` as a list
61 * item. An array may run over several lines ("dependencies = [" with one item per line). */

Callers 1

valueFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected