## String LuckyCase version to add methods directly to string by monkey patching * [String](#String) * [.letterCase(allow_prefixed_underscores)](#String+letterCase) → string \| null * [.letterCases(allow_prefixed_underscores)](#String+letterCases) → Array.<string> \| null * [.convertCase(case_type, preserve_prefixed_underscores)](#String+convertCase) → string * [.isValidCaseString()](#String+isValidCaseString) → boolean * [.toUpperCase()](#String+toUpperCase) → string * [.isUpperCase()](#String+isUpperCase) → boolean * [.toLowerCase()](#String+toLowerCase) → string * [.isLowerCase()](#String+isLowerCase) → boolean * [.toSnakeCase(preserve_prefixed_underscores)](#String+toSnakeCase) → string * [.isSnakeCase(allow_prefixed_underscores)](#String+isSnakeCase) → boolean * [.toUpperSnakeCase(preserve_prefixed_underscores)](#String+toUpperSnakeCase) → string * [.isUpperSnakeCase(allow_prefixed_underscores)](#String+isUpperSnakeCase) → boolean * [.toPascalCase(preserve_prefixed_underscores)](#String+toPascalCase) → string * [.isPascalCase(allow_prefixed_underscores)](#String+isPascalCase) → boolean * [.toCamelCase(preserve_prefixed_underscores)](#String+toCamelCase) → string * [.isCamelCase(allow_prefixed_underscores)](#String+isCamelCase) → boolean * [.toDashCase(preserve_prefixed_underscores)](#String+toDashCase) → string * [.isDashCase(allow_prefixed_underscores)](#String+isDashCase) → boolean * [.toUpperDashCase(preserve_prefixed_underscores)](#String+toUpperDashCase) → string * [.isUpperDashCase(allow_prefixed_underscores)](#String+isUpperDashCase) → boolean * [.toTrainCase(preserve_prefixed_underscores)](#String+toTrainCase) → string * [.isTrainCase(allow_prefixed_underscores)](#String+isTrainCase) → boolean * [.toWordCase(preserve_prefixed_underscores)](#String+toWordCase) → string * [.isWordCase(allow_prefixed_underscores)](#String+isWordCase) → boolean * [.toUpperWordCase(preserve_prefixed_underscores)](#String+toUpperWordCase) → string * [.isUpperWordCase(allow_prefixed_underscores)](#String+isUpperWordCase) → boolean * [.toCapitalWordCase(preserve_prefixed_underscores)](#String+toCapitalWordCase) → string * [.isCapitalWordCase(allow_prefixed_underscores)](#String+isCapitalWordCase) → boolean * [.toSentenceCase(preserve_prefixed_underscores)](#String+toSentenceCase) → string * [.isSentenceCase(allow_prefixed_underscores)](#String+isSentenceCase) → boolean * [.toCapital(skip_prefixed_underscores)](#String+toCapital) → string * [.capitalize(skip_prefixed_underscores)](#String+capitalize) → string * [.isCapital(skip_prefixed_underscores)](#String+isCapital) → boolean * [.isCapitalized(skip_prefixed_underscores)](#String+isCapitalized) → boolean * [.decapitalize(skip_prefixed_underscores)](#String+decapitalize) → string * [.isNotCapital(skip_prefixed_underscores)](#String+isNotCapital) → boolean * [.isDecapitalized(skip_prefixed_underscores)](#String+isDecapitalized) → boolean * [.toMixedCase(preserve_prefixed_underscores)](#String+toMixedCase) → string * [.isMixedCase(allow_prefixed_underscores)](#String+isMixedCase) → boolean * [.swapCase(preserve_prefixed_underscores)](#String+swapCase) → string * [.constantize()](#String+constantize) → any ### string.letterCase(allow_prefixed_underscores) → string \| null Get type of case of string (one key of LuckyCase.CASES) If more than one case matches, the first match wins. Match prio is the order of the regex in LuckyCase.CASES If you want or need to know all cases, use plural version of this method If you want to check explicitly for one case, use its check method, e.g. isSnakeCase(..) for 'SNAKE_CASE', etc... **Returns**: string \| null - string of caseType, null if no match | Param | Type | Default | | --- | --- | --- | | allow_prefixed_underscores | boolean | true | ### string.letterCases(allow_prefixed_underscores) → Array.<string> \| null Get types of cases of string (keys of LuckyCase.CASES) | Param | Type | Default | | --- | --- | --- | | allow_prefixed_underscores | boolean | true | ### string.convertCase(case_type, preserve_prefixed_underscores) → string Convert a string into the given case type | Param | Type | Default | Description | | --- | --- | --- | --- | | case_type | string | | can be UPPER_CASE or lower_case, e.g. 'SNAKE_CASE' or 'snake_case' | | preserve_prefixed_underscores | boolean | true | | ### string.isValidCaseString() → boolean Check if the string matches any of the available cases ### string.toUpperCase() → string Convert all characters inside the string into upper case **Example** ```js conversion 'this-isAnExample_string' => 'THIS-ISANEXAMPLE_STRING' ``` ### string.isUpperCase() → boolean Check if all characters inside the string are upper case ### string.toLowerCase() → string Convert all characters inside the string into lower case **Example** ```js conversion 'this-isAnExample_string' => 'this-isanexample_string' ``` ### string.isLowerCase() → boolean Check if all characters inside the string are lower case ### string.toSnakeCase(preserve_prefixed_underscores) → string Convert the string from any case into snake case | Param | Type | Default | | --- | --- | --- | | preserve_prefixed_underscores | boolean | true | **Example** ```js conversion 'this-isAnExample_string' => 'this_is_an_example_string' ``` ### string.isSnakeCase(allow_prefixed_underscores) → boolean Check if the string is snake case | Param | Type | Default | | --- | --- | --- | | allow_prefixed_underscores | boolean | true | ### string.toUpperSnakeCase(preserve_prefixed_underscores) → string Convert the string from any case into upper snake case | Param | Type | Default | | --- | --- | --- | | preserve_prefixed_underscores | boolean | true | **Example** ```js conversion 'this-isAnExample_string' => 'THIS_IS_AN_EXAMPLE_STRING' ``` ### string.isUpperSnakeCase(allow_prefixed_underscores) → boolean Check if the string is upper snake case | Param | Type | Default | | --- | --- | --- | | allow_prefixed_underscores | boolean | true | ### string.toPascalCase(preserve_prefixed_underscores) → string Convert the string from any case into pascal case | Param | Default | | --- | --- | | preserve_prefixed_underscores | true | **Example** ```js conversion 'this-isAnExample_string' => 'ThisIsAnExampleString' ``` ### string.isPascalCase(allow_prefixed_underscores) → boolean Check if the string is upper pascal case | Param | Type | Default | | --- | --- | --- | | allow_prefixed_underscores | boolean | true | ### string.toCamelCase(preserve_prefixed_underscores) → string Convert the string from any case into camel case | Param | Type | Default | | --- | --- | --- | | preserve_prefixed_underscores | boolean | true | **Example** ```js conversion 'this-isAnExample_string' => 'thisIsAnExampleString' ``` ### string.isCamelCase(allow_prefixed_underscores) → boolean Check if the string is camel case | Param | Type | Default | | --- | --- | --- | | allow_prefixed_underscores | boolean | true | ### string.toDashCase(preserve_prefixed_underscores) → string Convert the string from any case into dash case | Param | Type | Default | | --- | --- | --- | | preserve_prefixed_underscores | boolean | true | **Example** ```js conversion 'this-isAnExample_string' => 'this-is-an-example-string' ``` ### string.isDashCase(allow_prefixed_underscores) → boolean Check if the string is dash case | Param | Type | Default | | --- | --- | --- | | allow_prefixed_underscores | boolean | true | ### string.toUpperDashCase(preserve_prefixed_underscores) → string Convert the string from any case into upper dash case | Param | Type | Default | | --- | --- | --- | | preserve_prefixed_underscores | boolean | true | **Example** ```js conversion 'this-isAnExample_string' => 'THIS-IS-AN-EXAMPLE-STRING' ``` ### string.isUpperDashCase(allow_prefixed_underscores) → boolean Check if the string is upper dash case | Param | Type | Default | | --- | --- | --- | | allow_prefixed_underscores | boolean | true | ### string.toTrainCase(preserve_prefixed_underscores) → string Convert the string from any case into train case | Param | Type | Default | | --- | --- | --- | | preserve_prefixed_underscores | boolean | true | **Example** ```js conversion 'this-isAnExample_string' => 'This-Is-An-Example-String' ``` ### string.isTrainCase(allow_prefixed_underscores) → boolean Check if the string is train case | Param | Type | Default | | --- | --- | --- | | allow_prefixed_underscores | boolean | true | ### string.toWordCase(preserve_prefixed_underscores) → string Convert the string from any case into word case | Param | Type | Default | | --- | --- | --- | | preserve_prefixed_underscores | boolean | true | **Example** ```js conversion 'this-isAnExample_string' => 'this is an example string' ``` ### string.isWordCase(allow_prefixed_underscores) → boolean Check if the string is word case | Param | Default | | --- | --- | | allow_prefixed_underscores | true | ### string.toUpperWordCase(preserve_prefixed_underscores) → string Convert the string from any case into upper word case | Param | Type | Default | | --- | --- | --- | | preserve_prefixed_underscores | boolean | true | **Example** ```js conversion 'this-isAnExample_string' => 'THIS IS AN EXAMPLE STRING' ``` ### string.isUpperWordCase(allow_prefixed_underscores) → boolean Check if the string is upper word case | Param | Default | | --- | --- | | allow_prefixed_underscores | true | ### string.toCapitalWordCase(preserve_prefixed_underscores) → string Convert the string from any case into capital word case | Param | Type | Default | | --- | --- | --- | | preserve_prefixed_underscores | boolean | true | **Example** ```js conversion 'this-isAnExample_string' => 'This Is An Example String' ``` ### string.isCapitalWordCase(allow_prefixed_underscores) → boolean Check if the string is capital word case | Param | Type | Default | | --- | --- | --- | | allow_prefixed_underscores | boolean | true | ### string.toSentenceCase(preserve_prefixed_underscores) → string Convert the string from any case into sentence case | Param | Type | Default | | --- | --- | --- | | preserve_prefixed_underscores | boolean | true | **Example** ```js conversion 'this-isAnExample_string' => 'This is an example string' ``` ### string.isSentenceCase(allow_prefixed_underscores) → boolean Check if the string is sentence case | Param | Type | Default | | --- | --- | --- | | allow_prefixed_underscores | boolean | true | ### string.toCapital(skip_prefixed_underscores) → string Convert the first character to capital | Param | Type | Default | | --- | --- | --- | | skip_prefixed_underscores | boolean | false | ### string.capitalize(skip_prefixed_underscores) → string Convert the first character to capital | Param | Type | Default | | --- | --- | --- | | skip_prefixed_underscores | boolean | false | ### string.isCapital(skip_prefixed_underscores) → boolean Check if the strings first character is a capital letter | Param | Type | Default | | --- | --- | --- | | skip_prefixed_underscores | boolean | false | ### string.isCapitalized(skip_prefixed_underscores) → boolean Check if the strings first character is a capital letter | Param | Type | Default | | --- | --- | --- | | skip_prefixed_underscores | boolean | false | ### string.decapitalize(skip_prefixed_underscores) → string Convert the first character to lower case | Param | Type | Default | | --- | --- | --- | | skip_prefixed_underscores | boolean | false | ### string.isNotCapital(skip_prefixed_underscores) → boolean Check if the strings first character is a lower letter | Param | Type | Default | | --- | --- | --- | | skip_prefixed_underscores | boolean | false | ### string.isDecapitalized(skip_prefixed_underscores) → boolean Check if the strings first character is a lower letter | Param | Type | Default | | --- | --- | --- | | skip_prefixed_underscores | boolean | false | ### string.toMixedCase(preserve_prefixed_underscores) → string Convert the string from any case into mixed case. The new string is ensured to be different from the input. | Param | Type | Default | | --- | --- | --- | | preserve_prefixed_underscores | boolean | false | **Example** ```js conversion 'this-isAnExample_string' => 'This-Is_anExample-string' ``` ### string.isMixedCase(allow_prefixed_underscores) → boolean Check if the string is a valid mixed case (without special characters!) | Param | Type | Default | | --- | --- | --- | | allow_prefixed_underscores | boolean | true | ### string.swapCase(preserve_prefixed_underscores) → string Swaps character cases in string lower case to upper case upper case to lower case dash to underscore underscore to dash | Param | Type | Default | | --- | --- | --- | | preserve_prefixed_underscores | boolean | false | **Example** ```js conversion 'this-isAnExample_string' => 'THIS_ISaNeXAMPLE-STRING' ``` ### string.constantize() → any Convert the string from any case into pascal case and casts it into a constant **Example** ```js conversion 'this-isAnExample_string' => ThisIsAnExampleString 'this/is_an/example_path' => ThisIsAnExamplePath ```