Utility functions to determine and convert the case of strings.
import { toCamelCase } from 'case-convert'
const result = toCamelCase('a-new-hope') // aNewHope
export enum Case {
Camel = 'CAMEL', // camelCase
Snake = 'SNAKE', // snake_case
Kebab = 'KEBAB', // kebab-case
Title = 'TITLE', // TitleCase
}
Convert the string to the given case type
import { Case, convert } from 'case-convert'
const result = convert('a-new-hope', Case.Camel) // aNewHope
Check if the string is of the given case type
import { check, Case } from 'case-convert'
check('a-new-hope', Case.Camel) // false
check('a_new_hope', Case.Snake) // true
Determine the case type of the string
import { determineCase } from 'case-convert'
const result = determineCase('ANewHope') // Case.Title = "TITLE"
Capitalize or uncapitalize a string
import { capitalize, uncapitalize } from 'case-convert'
capitalize('a new hope') // A new hope
uncapitalize('A New Hope') // a New Hope
Convert the string to the given format
import { toCamelCase, toSnakeCase, toKebabCase, toTitleCase } from 'case-convert'
toCamelCase("some-string") // someString
toSnakeCase("someString") // some_string
toKebabCase("SomeString") // some-string
toTitleCase("some_string") // SomeString
This project is licensed under the MIT License.