(str: string | null | undefined)
| 10 | * capitalize(undefined) // '' |
| 11 | */ |
| 12 | export function capitalize(str: string | null | undefined): string { |
| 13 | if (!str) return ""; |
| 14 | return str.charAt(0).toUpperCase() + str.slice(1); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Safely capitalizes an error (or any value) after converting to string. |