From 54eb8173cf7ce35f29f4e9df309954bbd1cf7a5c Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Thu, 30 Sep 2021 10:16:29 +0300 Subject: [PATCH] made functions more rezilient --- src/lib/utils/functions.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/utils/functions.ts b/src/lib/utils/functions.ts index f3c6f9e..9ed07df 100644 --- a/src/lib/utils/functions.ts +++ b/src/lib/utils/functions.ts @@ -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(' '); }