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

Function lineOf

__tests__/operator-method-names.test.ts:25–29  ·  view source on GitHub ↗
(text: string, needle: string)

Source from the content-addressed store, hash-verified

23
24/** The 1-based line of `text` that contains `needle` (exactly one must). */
25const lineOf = (text: string, needle: string): number => {
26 const at = text.split('\n').map((l, i) => (l.includes(needle) ? i + 1 : 0)).filter(Boolean);
27 if (at.length !== 1) throw new Error(`${JSON.stringify(needle)} is on ${at.length} lines`);
28 return at[0]!;
29};
30
31const COUNTER_HPP = lines(
32 '#pragma once',

Callers 3

hppFunction · 0.70
cppFunction · 0.70

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected