[+] Create method to format string length

This commit is contained in:
Hykilpikonna
2019-10-20 20:23:47 -04:00
parent 4db8ee7837
commit fec6c77dc2
+11
View File
@@ -15,4 +15,15 @@ export class FormatUtils
// Convert to yyyy-mm-dd
return moment(date).format('YYYY-MM-DD');
}
/**
* Limit string length
*
* @param str String
* @param length Max length
*/
static limit(str: string, length: number): string
{
return str.length <= length ? str : str.substr(0, length - 2) + '...'
}
}