File tree Expand file tree Collapse file tree 1 file changed +2
-8
lines changed
projects/common/src/utilities/formatters/enum Expand file tree Collapse file tree 1 file changed +2
-8
lines changed Original file line number Diff line number Diff line change 1- import { isNil , startCase } from 'lodash-es' ;
1+ import { capitalize , isNil , lowerCase } from 'lodash-es' ;
22
33export 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} ;
You can’t perform that action at this time.
0 commit comments