CaseConversion
capitalizeInitial
Section titled “capitalizeInitial”Capitalizes the first letter of a word in a string.
Parameters
Section titled “Parameters”str
:string
- The input string.locales?
:Intl.LocalesArgument
- BCP 47 language tag(s) for case conversion (e.g., ‘en-US’).
Returns: string
Section titled “Returns: string”The string with the first letter capitalized.
function capitalizeInitial(str: string, locales?: Intl.LocalesArgument): string
capitalizeInitial('hello') // 'Hello'
capitalizeInitial(':> hello') // ':> Hello'
capitalizeWords
Section titled “capitalizeWords”Capitalizes the first letter of each word in a given string.
Parameters
Section titled “Parameters”str
:string
- The input string.locales?
:Intl.LocalesArgument
- BCP 47 language tag(s) for case conversion (e.g., ‘en-US’).
Returns: string
Section titled “Returns: string”The input string with the first letter of each word capitalized.
function capitalizeWords(str: string, locales?: Intl.LocalesArgument): string
capitalizeWords('hello world') // 'Hello World'
capitalizeWords('This was your big idea, remember?') // 'This Was Your Big Idea, Remember?'
snakeCase
Section titled “snakeCase”Converts a string to snake_case format.
Parameters
Section titled “Parameters”str
:string
- The input string.inWords
:boolean
If true, converts numbers to words in snake_case format.locales?
:Intl.LocalesArgument
- BCP 47 language tag(s) for case conversion (e.g., ‘en-US’).
Returns: string
Section titled “Returns: string”The string converted to snake_case format.
function snakeCase(str: string, inWords?: boolean, locales?: Intl.LocalesArgument): string
snakeCase('hello WorLd') // 'hello_world'snakeCase('from-kebab-case') // 'from_kebab_case'snakeCase('snake Case With Numbers123', true) // 'snake_case_with_numbers_one_two_three'
kebabCase
Section titled “kebabCase”Converts a string to kebab-case format.
Parameters
Section titled “Parameters”str
:string
- The input string.inWords
:boolean
If true, converts numbers to words in kebab-case format.locales?
:Intl.LocalesArgument
- BCP 47 language tag(s) for case conversion (e.g., ‘en-US’).
Returns: string
Section titled “Returns: string”The string converted to kebab-case format.
function kebabCase(str: string, inWords?: boolean, locales?: Intl.LocalesArgument): string
kebabCase('h3llo WoRld') // 'h3llo-world'kebabCase('from_snake_case') // 'from-snake-case'kebabCase('kebab Case With Numbers123', true) // 'kebab-case-with-numbers-one-two-three'
camelCase
Section titled “camelCase”Converts a string to camelCase format.
Parameters
Section titled “Parameters”str
:string
- The input string.locales?
:Intl.LocalesArgument
- BCP 47 language tag(s) for case conversion (e.g., ‘en-US’).
Returns: string
Section titled “Returns: string”The string converted to camelCase format.
function camelCase(str: string, locales?: Intl.LocalesArgument): string
camelCase('hello WoRld') // 'helloWorld'camelCase('Test CaSe ExamplE') // 'testCaseExample'camelCase('camel Case With Numbers123') // 'camelCaseWithNumbers'
pascalCase
Section titled “pascalCase”Converts a string to PascalCase format.
Parameters
Section titled “Parameters”str
:string
- The input string.locales?
:Intl.LocalesArgument
- BCP 47 language tag(s) for case conversion (e.g., ‘en-US’).
Returns: string
Section titled “Returns: string”The string converted to PascalCase format.
function PascalCase(str: string, locales?: Intl.LocalesArgument): string
pascalCase('hello WoRld') // 'HelloWorld'pascalCase('Test CaSe ExamplE') // 'TestCaseExample'pascalCase('pasCal Case With Numbers123') // 'PascalCaseWithNumbers'