MCPcopy Create free account
hub / github.com/anus-dev/ANUS / countOccurrences

Function countOccurrences

packages/core/src/utils/editCorrector.ts:735–746  ·  view source on GitHub ↗
(str: string, substr: string)

Source from the content-addressed store, hash-verified

733 * Counts occurrences of a substring in a string
734 */
735export function countOccurrences(str: string, substr: string): number {
736 if (substr === '') {
737 return 0;
738 }
739 let count = 0;
740 let pos = str.indexOf(substr);
741 while (pos !== -1) {
742 count++;
743 pos = str.indexOf(substr, pos + substr.length); // Start search after the current match
744 }
745 return count;
746}
747
748export function resetEditCorrectorCaches_TEST_ONLY() {
749 editCorrectionCache.clear();

Callers 3

ensureCorrectEditFunction · 0.85
trimPairIfPossibleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected