fix: throws on invalid arguments for prepend/append, fixes #208

This commit is contained in:
harttle
2020-03-24 23:57:26 +08:00
parent 60c14ba057
commit 479c63350a
13 changed files with 163 additions and 113 deletions
+7
View File
@@ -120,6 +120,13 @@ export function identify<T> (val: T): T {
return val
}
export function snakeCase (str: string) {
return str.replace(
/(\w?)([A-Z])/g,
(_, a, b) => (a ? a + '_' : '') + b.toLowerCase()
)
}
export function changeCase (str: string): string {
const hasLowerCase = [...str].some(ch => ch >= 'a' && ch <= 'z')
return hasLowerCase ? str.toUpperCase() : str.toLowerCase()