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

Function mentionCount

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

Source from the content-addressed store, hash-verified

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