import { Injectable } from '@angular/core' ; @ Injectable ( ) export class WsCaseService { constructor ( ) { } private joinStrings ( toJoin , delimiter ) { return toJoin . map ( x => x ) . join ( delimiter ) ; } private lowerCase ( toLower ) { return toLower . toLowerCase ( ) ; } public snakeCaseToStrings ( snakeCase ) { return snakeCase . split ( "_" ) ; } private snakeCaseToTitles ( snakeCase ) { let snakeSplit = this . snakeCaseToStrings ( snakeCase ) ; return this . titleCases ( snakeSplit ) ; } public snakeCaseToSpacedTitleCase ( snakeCase ) { let snakeTitles = this . snakeCaseToTitles ( snakeCase ) ; return this . joinStrings ( snakeTitles , " " ) ; } public snakeCaseToTitleCase ( snakeCase ) { let snakeTitles = this . snakeCaseToTitles ( snakeCase ) ; return this . joinStrings ( snakeTitles , "" ) ; } public titleCase ( toTitle ) { return toTitle . charAt ( 0 ) . toUpperCase ( ) + toTitle . slice ( 1 ) ; } public titleCases ( toTitles ) { let toReturn = [ ] ; for ( let toTitle of toTitles ) { toReturn . push ( this . titleCase ( toTitle ) ) ; } return toReturn ; } }