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

Function findHeaderIndex

src/installer/targets/toml.ts:128–134  ·  view source on GitHub ↗

* Locate the byte index of a header line (`[foo.bar]`) when it * appears at the start of a line. Returns -1 if not found.

(content: string, headerLine: string)

Source from the content-addressed store, hash-verified

126 * appears at the start of a line. Returns -1 if not found.
127 */
128function findHeaderIndex(content: string, headerLine: string): number {
129 // Search BOL or right after a newline.
130 if (content.startsWith(headerLine)) return 0;
131 const needle = '\n' + headerLine;
132 const idx = content.indexOf(needle);
133 return idx === -1 ? -1 : idx + 1;
134}
135
136/**
137 * Find the byte index of the next `[...]` or `[[...]]` table header

Callers 2

upsertTomlTableFunction · 0.85
removeTomlTableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected