Skip to content

Commit a49ff74

Browse files
committed
fix: simplify
1 parent 4441e0b commit a49ff74

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
import { isNil, startCase } from 'lodash-es';
1+
import { capitalize, isNil, lowerCase } from 'lodash-es';
22

33
export const displayStringEnum = (provided?: string, defaultValue: string = '-', separator: string = ' '): string => {
44
if (isNil(provided)) {
55
return defaultValue;
66
}
77

8-
// This removes dashes and underscores and gives all words initial caps
9-
const startCased = startCase(provided);
10-
11-
const startCasedSeparated = startCased.replace(' ', separator);
12-
13-
// We only want the first word capitalized.
14-
return `${startCasedSeparated[0]}${startCasedSeparated.substr(1).toLowerCase()}`;
8+
return capitalize(lowerCase(provided)).replace(' ', separator);
159
};

0 commit comments

Comments
 (0)