test(ngcc): tidy up helper function (#34135)
Thanks to @gkalpakl for the better regular expression approach. PR Close #34135
This commit is contained in:
parent
67eac733d2
commit
e12933a3aa
|
@ -1293,10 +1293,6 @@ runInEachFileSystem(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function countOccurrences(haystack: string, needle: string): number {
|
function countOccurrences(haystack: string, needle: string): number {
|
||||||
const regex = new RegExp(needle, 'g');
|
const matches = haystack.match(new RegExp(needle, 'g'));
|
||||||
let count = 0;
|
return matches !== null ? matches.length : 0;
|
||||||
while (regex.exec(haystack)) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue