MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / extractExports

Function extractExports

src/tools/codegraph/find-dead-code.ts:140–158  ·  view source on GitHub ↗

Extract `export` names (ES/TS only) from file content. Imperfect but pragmatic.

(content: string)

Source from the content-addressed store, hash-verified

138
139/** Extract `export` names (ES/TS only) from file content. Imperfect but pragmatic. */
140function extractExports(content: string): { name: string; line: number }[] {
141 const out: { name: string; line: number }[] = [];
142 const lines = content.split('\n');
143 const reExportNamed = /^\s*export\s+(?:async\s+)?(?:function|class|const|let|var|interface|type|enum)\s+([A-Za-z_$][\w$]*)/;
144 const reExportBlock = /^\s*export\s+\{([^}]+)\}/;
145 for (let i = 0; i < lines.length; i++) {
146 const line = lines[i]!;
147 const m1 = reExportNamed.exec(line);
148 if (m1) out.push({ name: m1[1]!, line: i + 1 });
149 const m2 = reExportBlock.exec(line);
150 if (m2) {
151 for (const part of m2[1]!.split(',')) {
152 const name = part.trim().split(/\s+as\s+/)[0]!.trim();
153 if (name) out.push({ name, line: i + 1 });
154 }
155 }
156 }
157 return out;
158}
159
160/** Extract local (non-exported) function declarations. */
161function extractLocalFunctions(content: string): { name: string; line: number }[] {

Callers 1

executeMethod · 0.70

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected