All checks were successful
Deploy / deploy (ubuntu-latest, 2.44.0) (push) Successful in 4m1s
Took 13 minutes
19 lines
535 B
TypeScript
19 lines
535 B
TypeScript
/**
|
|
* Capitalize the first letter of
|
|
* each word in the given string.
|
|
*
|
|
* @param str the string to capitalize
|
|
* @return the capitalized string
|
|
*/
|
|
export const capitalizeWords = (str: string | undefined): string | undefined =>
|
|
str &&
|
|
str.toLowerCase().replace(/\b\w/g, (char: string) => char.toUpperCase());
|
|
|
|
export const truncateText = (
|
|
text: string | undefined,
|
|
maxLength: number
|
|
): string | undefined =>
|
|
text && text.length > maxLength
|
|
? text.slice(0, maxLength - 3).trim() + "..."
|
|
: text;
|