(text: string[])
| 42 | * @returns The formatted, human-readable string. |
| 43 | */ |
| 44 | export function formatForDisplay(text: string[]): string { |
| 45 | if (!text) { |
| 46 | return ''; |
| 47 | } |
| 48 | |
| 49 | return formatProperCase( |
| 50 | text |
| 51 | .join(' ') |
| 52 | .replace(/([a-z])([A-Z])/g, '$1 $2') // Add space between lowercase character followed by an uppercase character |
| 53 | .replaceAll('_', ' ') // Replace underscores with spaces |
| 54 | .trim(), |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Formats a string to proper case (capitalize the first letter of each word). |
no test coverage detected