@wtasnorg/node-lib / countString
countString(
s,substr):number
Defined in: src/strings.ts:236
Count counts the number of non-overlapping instances of substr in s. If substr is an empty string, Count returns 1 + the number of Unicode code points in s.
string
Input string.
string
Substring to count.
number
Number of non-overlapping occurrences.
count("cheese", "e"); // 3
count("five", ""); // 5 (empty substr → rune count + 1)
count("", ""); // 1
count("", "foo"); // 0 — substr longer than s