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

Function mentionCount

src/graph/dead-code.ts:735–748  ·  view source on GitHub ↗
(source: string, name: string, stopAt = Number.MAX_SAFE_INTEGER)

Source from the content-addressed store, hash-verified

733 * JavaScript and an identifier may not be.
734 */
735export function mentionCount(source: string, name: string, stopAt = Number.MAX_SAFE_INTEGER): number {
736 if (name.length === 0) return 0;
737 let count = 0;
738 let from = 0;
739 for (;;) {
740 const at = source.indexOf(name, from);
741 if (at < 0) return count;
742 from = at + name.length;
743 if (!isIdentifierChar(source[at - 1]) && !isIdentifierChar(source[from])) {
744 count += 1;
745 if (count >= stopAt) return count;
746 }
747 }
748}
749
750function isIdentifierChar(char: string | undefined): boolean {
751 if (char === undefined) return false;

Callers 2

dead-code.test.tsFile · 0.90
buildDeadCodeReportFunction · 0.85

Calls 1

isIdentifierCharFunction · 0.85

Tested by

no test coverage detected