Merge pull request 'Correctly Capatilize After Opening Bracket' (#8) from Jera/deemix-js:jera-patch-1 into main

Reviewed-on: https://git.freezer.life/RemixDev/deemix-js/pulls/8
This commit is contained in:
RemixDev 2021-09-03 03:05:16 -04:00
commit a2eff225f3

View file

@ -25,7 +25,13 @@ function changeCase(txt, type){
case 'upper': return txt.toUpperCase()
case 'start':
txt = txt.split(" ")
for (let i = 0; i < txt.length; i++) txt[i] = txt[i][0].toUpperCase() + txt[i].substr(1).toLowerCase()
for (let i = 0; i < txt.length; i++) {
if (bracket = ['(', '{', '['].some(bracket => txt[i].startsWith(bracket))) {
txt[i] = txt[i][0] + txt[i][1].toUpperCase() + txt[i].substr(2).toLowerCase()
} else {
txt[i] = txt[i][0].toUpperCase() + txt[i].substr(1).toLowerCase()
}
}
return txt.join(" ")
case 'sentence': return txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase()
default: return txt