made functions more rezilient
This commit is contained in:
parent
1ab7d6bbad
commit
54eb8173cf
@ -1,12 +1,18 @@
|
||||
import { tap } from 'rxjs/operators';
|
||||
import {tap} from 'rxjs/operators';
|
||||
|
||||
export function capitalize(value: string): string {
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
return value.charAt(0).toUpperCase() + value.slice(1);
|
||||
}
|
||||
|
||||
export function humanize(value: string, lowercase = true): string {
|
||||
const words = (lowercase ? value.toLowerCase() : value).split(/[ \-_]+/);
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const words = (lowercase ? value.toLowerCase() : value).split(/[ \-_]+/);
|
||||
return words.map(capitalize).join(' ');
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user