forked from mirrors/homebox
15 lines
365 B
TypeScript
15 lines
365 B
TypeScript
|
export function titlecase(str: string) {
|
||
|
return str
|
||
|
.split(" ")
|
||
|
.map(word => word[0].toUpperCase() + word.slice(1))
|
||
|
.join(" ");
|
||
|
}
|
||
|
|
||
|
export function capitalize(str: string) {
|
||
|
return str[0].toUpperCase() + str.slice(1);
|
||
|
}
|
||
|
|
||
|
export function truncate(str: string, length: number) {
|
||
|
return str.length > length ? str.substring(0, length) + "..." : str;
|
||
|
}
|