(
str: { indexOf(search: string, start?: number): number },
char: string,
start = 0,
)
| 52 | * (Buffer.indexOf accepts string needles). |
| 53 | */ |
| 54 | export function countCharInString( |
| 55 | str: { indexOf(search: string, start?: number): number }, |
| 56 | char: string, |
| 57 | start = 0, |
| 58 | ): number { |
| 59 | let count = 0 |
| 60 | let i = str.indexOf(char, start) |
| 61 | while (i !== -1) { |
| 62 | count++ |
| 63 | i = str.indexOf(char, i + 1) |
| 64 | } |
| 65 | return count |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Normalize full-width (zenkaku) digits to half-width digits. |
no outgoing calls
no test coverage detected