(str: string, substr: string)
| 733 | * Counts occurrences of a substring in a string |
| 734 | */ |
| 735 | export 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 | |
| 748 | export function resetEditCorrectorCaches_TEST_ONLY() { |
| 749 | editCorrectionCache.clear(); |
no outgoing calls
no test coverage detected