[+] Encapsulate toTitleCase()
This commit is contained in:
@@ -22,8 +22,19 @@ export class FormatUtils
|
|||||||
* @param str String
|
* @param str String
|
||||||
* @param length Max length
|
* @param length Max length
|
||||||
*/
|
*/
|
||||||
static limit(str: string, length: number): string
|
public static limit(str: string, length: number): string
|
||||||
{
|
{
|
||||||
return str.length <= length ? str : str.substr(0, length - 2) + '...'
|
return str.length <= length ? str : str.substr(0, length - 2) + '...'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To Title Case
|
||||||
|
*
|
||||||
|
* @param str oRigInAL sTrING
|
||||||
|
* @return string Original String
|
||||||
|
*/
|
||||||
|
public static toTitleCase(str: string)
|
||||||
|
{
|
||||||
|
return str.replace(/\w\S*/g, s => s.charAt(0).toUpperCase() + s.substr(1).toLowerCase())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user