### Install Dependencies Source: https://github.com/magynhard/lucky-case/blob/master/doc/developer.md Use this command to install project dependencies, ignoring engine restrictions for compatibility. ```bash yarn install --ignore-engines ``` -------------------------------- ### Example of constantize conversion Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Shows how to convert a string from any case into PascalCase and then cast it into a constant. Note potential scope issues in Node.js environments. ```javascript conversion 'this-isAnExample_string' => ThisIsAnExampleString 'this/is_an/example_path' => ThisIsAnExamplePath ``` -------------------------------- ### Example of toMixedCase conversion Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Demonstrates converting a string from various cases into mixed case. The output string is guaranteed to be different from the input. ```javascript conversion 'this-isAnExample_string' => 'This-Is_anExample-string' ``` -------------------------------- ### Example of swapCase conversion Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Illustrates swapping character cases (lowercase to uppercase, uppercase to lowercase) and converting dashes to underscores and vice versa. ```javascript conversion 'this-isAnExample_string' => 'THIS_ISaNeXAMPLE-STRING' ``` -------------------------------- ### Example of deconstantize conversion Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Demonstrates de-converting a constant (or function name) back into a specified string case type. This function may have limitations in certain Node.js scopes. ```javascript deconversion ThisAweSomeConstant => 'thisAweSomeConstant' function myFunction() {} => 'myFunction' ``` -------------------------------- ### LuckyCase.getVersion Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Gets the current version of the LuckyCase library. ```APIDOC ## LuckyCase.getVersion ### Description Gets the current version of the LuckyCase library. ### Method N/A (Static method) ### Returns `string` - The version of the library. ``` -------------------------------- ### Using LuckyCase Static Class for Case Checking Source: https://github.com/magynhard/lucky-case/blob/master/README.md Provides examples of various checker methods available in the LuckyCase static class to validate if a string conforms to specific case formats like snake_case, PascalCase, camelCase, dash-case, etc., and also checks for general upper/lower case and capitalization. ```javascript // checkers LuckyCase.isSnakeCase('valid_snake_case') // => true LuckyCase.isUpperSnakeCase('UPPER_SNAKE') // => true LuckyCase.isPascalCase('PascalCase') // => true LuckyCase.isCamelCase('toCamelCase') // => true LuckyCase.isDashCase('dash-case') // => true LuckyCase.isUpperDashCase('DASH-CASE') // => true LuckyCase.isTrainCase('Train-Case') // => true LuckyCase.isWordCase('word case') // => true LuckyCase.isUpperWordCase('UPPER WORD CASE') // => true LuckyCase.isCapitalWordCase('Capital Word Case') // => true LuckyCase.isSentenceCase('Sentence case string') // => true LuckyCase.isMixedCase('mixed_Case') // => true LuckyCase.isUpperCase('UPPER50984') // => true LuckyCase.isLowerCase('lower_cheese') // => true LuckyCase.isCapital('Some') // => true LuckyCase.isCapitalized('some') // => false LuckyCase.isNotCapital('soMe') // => true LuckyCase.isDecapitalized('somE') // => true LuckyCase.isValidCaseType('SNAKE_CASE') // => true LuckyCase.isValidCaseType('APPLE_CASE') // => false LuckyCase.isValidCaseString('validString') // => true LuckyCase.isValidCaseString('1nV4lid$tring') // => false ``` -------------------------------- ### Using LuckyCase Static Class for Identifiers Source: https://github.com/magynhard/lucky-case/blob/master/README.md Shows how to use the LuckyCase static class to determine the case type of a string or to get a list of possible case types for a given string. ```javascript // identifiers LuckyCase.case('this_can_only_be_snake_case') // => 'SNAKE_CASE' LuckyCase.cases('validformultiple') // => [ 'SNAKE_CASE', 'CAMEL_CASE', 'DASH_CASE', 'WORD_CASE' ] ``` -------------------------------- ### LuckyCase.isCapitalized Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Checks if the first character of a string is an uppercase letter. It can optionally skip checking if the string starts with underscores. ```APIDOC ## LuckyCase.isCapitalized(string, skip_prefixed_underscores) ### Description Check if the strings first character is a capital letter. ### Parameters #### Path Parameters - **string** (string) - Required - The input string to check. - **skip_prefixed_underscores** (boolean) - Optional - If true, underscores at the beginning of the string will be ignored. Defaults to false. ### Returns - **boolean** - True if the first character is capitalized, false otherwise. ``` -------------------------------- ### String.prototype.toTrainCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to Train-Case. ```APIDOC ## String.prototype.toTrainCase(preserve_prefixed_underscores) ### Description Convert string to Train-Case. ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines whether to preserve prefixed underscores during conversion. ### Returns - **string** - The Train-Case version of the string. ``` -------------------------------- ### LuckyCase.getUnderscoresAtStart Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Retrieves and returns all leading underscores from the beginning of a string. ```APIDOC ## LuckyCase.getUnderscoresAtStart(string) ### Description Return the underscores at the start of the string. ### Parameters #### Path Parameters - **string** (string) - Required - The input string. ### Returns - **string** - A string consisting of only the leading underscores, or an empty string if none are found. ``` -------------------------------- ### string.toTrainCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts a string from any case into train case. It can optionally preserve prefixed underscores. ```APIDOC ## string.toTrainCase(preserve_prefixed_underscores) ### Description Convert the string from any case into train case. ### Parameters #### Path Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be preserved. ### Request Example ```js conversion 'this-isAnExample_string' => 'This-Is-An-Example-String' ``` ``` -------------------------------- ### String.prototype.capitalize Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Alias for `toCapital`. Capitalizes the first letter of the string. ```APIDOC ## String.prototype.capitalize(skip_prefixed_underscores) ### Description Alias for `toCapital`. Capitalize the first letter of the string. ### Parameters #### Query Parameters - **skip_prefixed_underscores** (boolean) - Optional - Defaults to `false`. Determines whether to skip capitalizing if the string starts with prefixed underscores. ### Returns - **string** - The string with its first letter capitalized. ``` -------------------------------- ### String.prototype.toPascalCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to PascalCase. ```APIDOC ## String.prototype.toPascalCase(preserve_prefixed_underscores) ### Description Convert string to PascalCase. ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines whether to preserve prefixed underscores during conversion. ### Returns - **string** - The PascalCase version of the string. ``` -------------------------------- ### String.prototype.toSentenceCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to Sentence case. ```APIDOC ## String.prototype.toSentenceCase(preserve_prefixed_underscores) ### Description Convert string to Sentence case. ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines whether to preserve prefixed underscores during conversion. ### Returns - **string** - The Sentence case version of the string. ``` -------------------------------- ### String.prototype.toDashCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to dash-case. ```APIDOC ## String.prototype.toDashCase(preserve_prefixed_underscores) ### Description Convert string to dash-case. ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines whether to preserve prefixed underscores during conversion. ### Returns - **string** - The dash-case version of the string. ``` -------------------------------- ### string.toPascalCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to PascalCase, with an option to preserve prefixed underscores. ```APIDOC ## string.toPascalCase(preserve_prefixed_underscores) ### Description Convert the string from any case into pascal case ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true` ### Example ```js conversion 'this-isAnExample_string' => 'ThisIsAnExampleString' ``` ### Returns - string ``` -------------------------------- ### String.prototype.toWordCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to Word Case. ```APIDOC ## String.prototype.toWordCase(preserve_prefixed_underscores) ### Description Convert string to Word Case. ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines whether to preserve prefixed underscores during conversion. ### Returns - **string** - The Word Case version of the string. ``` -------------------------------- ### Using Lucky Case String Methods Source: https://github.com/magynhard/lucky-case/blob/master/README.md Demonstrates calling Lucky Case methods directly on string variables after importing the string module. ```javascript let a = 'ExampleString' a.isPascalCase() // => true a.toSnakeCase() // => 'example_string' a // => 'ExampleString' ``` -------------------------------- ### string.toDashCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to dash-case, with an option to preserve prefixed underscores. ```APIDOC ## string.toDashCase(preserve_prefixed_underscores) ### Description Convert the string from any case into dash case ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true` ### Example ```js conversion 'this-isAnExample_string' => 'this-is-an-example-string' ``` ### Returns - string ``` -------------------------------- ### Using General Lucky Case Methods on Strings Source: https://github.com/magynhard/lucky-case/blob/master/README.md Shows how to use the general case conversion methods 'letterCase' and 'letterCases' on strings, which are aliased to avoid potential conflicts with common method names. ```javascript // identifiers // got a other method name here because 'case' might be to common and cause conflicts b = 'example' b.letterCase() // => 'SNAKE_CASE' b.letterCases() // => [ 'SNAKE_CASE', 'CAMEL_CASE', 'DASH_CASE', 'WORD_CASE' ] ``` -------------------------------- ### String.prototype.toCapitalWordCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to Capital Word Case. ```APIDOC ## String.prototype.toCapitalWordCase(preserve_prefixed_underscores) ### Description Convert string to Capital Word Case. ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines whether to preserve prefixed underscores during conversion. ### Returns - **string** - The Capital Word Case version of the string. ``` -------------------------------- ### string.toUpperDashCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to UPPER-DASH-CASE. ```APIDOC ## string.toUpperDashCase() ### Description Convert the string from any case into upper dash case ### Returns - string ``` -------------------------------- ### String.prototype.toUpperCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the entire string to uppercase. ```APIDOC ## String.prototype.toUpperCase() ### Description Convert string to upper case. ### Returns - **string** - The uppercase version of the string. ``` -------------------------------- ### Using LuckyCase Static Class for Transformations Source: https://github.com/magynhard/lucky-case/blob/master/README.md Illustrates string transformation methods provided by the LuckyCase static class. This includes changing case to lower, upper, capitalizing, decapitalizing, swapping case, and converting to/from constant case. ```javascript // transformers LuckyCase.toLowerCase('Some_FuckingShit') // => 'some_fuckingshit' LuckyCase.toUpperCase('Some_FuckingShit') // => 'SOME_FUCKINGSHIT' LuckyCase.toCapital('example') // => 'Example' LuckyCase.capitalize('exAmple') // => 'ExAmple' LuckyCase.decapitalize('ExAmple') // => 'exAmple' LuckyCase.swapCase('SomeSwappy_Case-Example') // => 'sOMEsWAPPY-cASE_eXAMPLE' LuckyCase.constantize('some_constant') // => SomeConstant LuckyCase.constantize('SOME_CONSTANT') // => SomeConstant LuckyCase.constantize('some/path_example/folder') // => SomePathExampleFolder LuckyCase.deconstantize(SomeConstant) // => 'someConstant' // default caseType: 'CAMEL_CASE' LuckyCase.deconstantize(SomeConstant, caseType: 'SNAKE_CASE') // => 'some_constant' ``` -------------------------------- ### string.toSentenceCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts a string from any case into sentence case. It can optionally preserve prefixed underscores. ```APIDOC ## string.toSentenceCase(preserve_prefixed_underscores) ### Description Convert the string from any case into sentence case. ### Parameters #### Path Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be preserved. ### Request Example ```js conversion 'this-isAnExample_string' => 'This is an example string' ``` ``` -------------------------------- ### string.toCapitalWordCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts a string from any case into capital word case. It can optionally preserve prefixed underscores. ```APIDOC ## string.toCapitalWordCase(preserve_prefixed_underscores) ### Description Convert the string from any case into capital word case. ### Parameters #### Path Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be preserved. ### Request Example ```js conversion 'this-isAnExample_string' => 'This Is An Example String' ``` ``` -------------------------------- ### String.prototype.isTrainCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if the string is in Train-Case format. ```APIDOC ## String.prototype.isTrainCase(allow_prefixed_underscores) ### Description Check if string is Train-Case. ### Parameters #### Query Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be considered when checking for Train-Case. ### Returns - **boolean** - True if the string is in Train-Case format, false otherwise. ``` -------------------------------- ### String.prototype.toCapital Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Capitalizes the first letter of the string. ```APIDOC ## String.prototype.toCapital(skip_prefixed_underscores) ### Description Capitalize the first letter of the string. ### Parameters #### Query Parameters - **skip_prefixed_underscores** (boolean) - Optional - Defaults to `false`. Determines whether to skip capitalizing if the string starts with prefixed underscores. ### Returns - **string** - The string with its first letter capitalized. ``` -------------------------------- ### string.toCapital Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the first character of a string to capital. It can optionally skip prefixed underscores. ```APIDOC ## string.toCapital(skip_prefixed_underscores) ### Description Convert the first character to capital. ### Parameters #### Path Parameters - **skip_prefixed_underscores** (boolean) - Optional - Defaults to `false`. Determines if prefixed underscores should be skipped. ### Request Example ```js conversion 'this is an example string' => 'This is an example string' ``` ``` -------------------------------- ### String.prototype.constantize Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to a constant-like format, typically all uppercase with underscores. ```APIDOC ## String.prototype.constantize() ### Description Convert string to constant case (e.g., 'my_variable' to 'MY_VARIABLE'). ### Returns - **any** - The constantized string. The return type is 'any' as per the source, though typically a string. ``` -------------------------------- ### LuckyCase.toTrainCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a string to Train-Case, optionally preserving prefixed underscores. ```APIDOC ## LuckyCase.toTrainCase ### Description Converts a string to Train-Case, optionally preserving prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to convert. * `preserve_prefixed_underscores` (boolean) - Whether to preserve prefixed underscores. ### Returns `string` - The Train-Case version of the string. ``` -------------------------------- ### string.toUpperCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts all characters in the string to uppercase. ```APIDOC ## string.toUpperCase() ### Description Convert all characters inside the string into upper case ### Example ```js conversion 'this-isAnExample_string' => 'THIS-ISANEXAMPLE_STRING' ``` ### Returns - string ``` -------------------------------- ### String.prototype.toUpperDashCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to UPPER-DASH-CASE. ```APIDOC ## String.prototype.toUpperDashCase(preserve_prefixed_underscores) ### Description Convert string to UPPER-DASH-CASE. ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines whether to preserve prefixed underscores during conversion. ### Returns - **string** - The UPPER-DASH-CASE version of the string. ``` -------------------------------- ### string.toWordCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts a string from any case into word case. It can optionally preserve prefixed underscores. ```APIDOC ## string.toWordCase(preserve_prefixed_underscores) ### Description Convert the string from any case into word case. ### Parameters #### Path Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be preserved. ### Request Example ```js conversion 'this-isAnExample_string' => 'this is an example string' ``` ``` -------------------------------- ### string.toCamelCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to camelCase, with an option to preserve prefixed underscores. ```APIDOC ## string.toCamelCase(preserve_prefixed_underscores) ### Description Convert the string from any case into camel case ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true` ### Example ```js conversion 'this-isAnExample_string' => 'thisIsAnExampleString' ``` ### Returns - string ``` -------------------------------- ### Using LuckyCase Static Class for Conversions Source: https://github.com/magynhard/lucky-case/blob/master/README.md Demonstrates various string case conversion methods available through the static LuckyCase class. These include converting to snake_case, Upper_Snake_Case, PascalCase, camelCase, dash-case, and more. Also shows a generic convertCase method. ```javascript // node js const LuckyCase = require('lucky-case'); // browser // converters LuckyCase.toSnakeCase('PascalToSnake') // => 'pascal_to_snake' LuckyCase.toUpperSnakeCase('Train-To-Upper-Snake') // => 'TRAIN_TO_UPPER_SNAKE' LuckyCase.toPascalCase('snake_to_pascal') // => 'SnakeToPascal' LuckyCase.toCamelCase('dash-to-camel-case') // => 'dashToCamelCase' LuckyCase.toDashCase('PascalToDashCase') // => 'pascal-to-dash-case' LuckyCase.toUpperDashCase('PascalToUpperDash') // => 'PASCAL-TO-UPPER-DASH' LuckyCase.toTrainCase('snake_to_train_case') // => 'Snake-To-Train-Case' LuckyCase.toWordCase('PascalToWordCase') // => 'pascal to word case' LuckyCase.toUpperWordCase('PascalToUpperWord') // => 'PASCAL TO UPPER WORD' LuckyCase.toCapitalWordCase('snake_to_capital_word') // => 'Snake To Capital Word' LuckyCase.toSentenceCase('snake_to_sentence_case') // => 'Snake to sentence case' LuckyCase.toMixedCase('example_snake_string') // => 'Example-snake_STRING' // converter by type LuckyCase.convertCase('some_snake', 'PASCAL_CASE') // => 'SomeSnake' ``` -------------------------------- ### String.prototype.toCamelCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to camelCase. ```APIDOC ## String.prototype.toCamelCase(preserve_prefixed_underscores) ### Description Convert string to camelCase. ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines whether to preserve prefixed underscores during conversion. ### Returns - **string** - The camelCase version of the string. ``` -------------------------------- ### string.capitalize Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the first character of a string to capital. It can optionally skip prefixed underscores. ```APIDOC ## string.capitalize(skip_prefixed_underscores) ### Description Convert the first character to capital. ### Parameters #### Path Parameters - **skip_prefixed_underscores** (boolean) - Optional - Defaults to `false`. Determines if prefixed underscores should be skipped. ### Request Example ```js conversion 'this is an example string' => 'This is an example string' ``` ``` -------------------------------- ### String.prototype.isSentenceCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if the string is in Sentence case format. ```APIDOC ## String.prototype.isSentenceCase(allow_prefixed_underscores) ### Description Check if string is Sentence case. ### Parameters #### Query Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be considered when checking for Sentence case. ### Returns - **boolean** - True if the string is in Sentence case format, false otherwise. ``` -------------------------------- ### string.toUpperWordCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts a string from any case into upper word case. It can optionally preserve prefixed underscores. ```APIDOC ## string.toUpperWordCase(preserve_prefixed_underscores) ### Description Convert the string from any case into upper word case. ### Parameters #### Path Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be preserved. ### Request Example ```js conversion 'this-isAnExample_string' => 'THIS IS AN EXAMPLE STRING' ``` ``` -------------------------------- ### String.prototype.isWordCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if the string is in Word Case format. ```APIDOC ## String.prototype.isWordCase(allow_prefixed_underscores) ### Description Check if string is Word Case. ### Parameters #### Query Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be considered when checking for Word Case. ### Returns - **boolean** - True if the string is in Word Case format, false otherwise. ``` -------------------------------- ### string.toUpperDashCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts a string from any case into upper dash case. It can optionally preserve prefixed underscores. ```APIDOC ## string.toUpperDashCase(preserve_prefixed_underscores) ### Description Convert the string from any case into upper dash case. ### Parameters #### Path Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be preserved. ### Request Example ```js conversion 'this-isAnExample_string' => 'THIS-IS-AN-EXAMPLE-STRING' ``` ``` -------------------------------- ### Import Lucky Case for String Monkey Patching Source: https://github.com/magynhard/lucky-case/blob/master/README.md Import the Lucky Case string module for Node.js or include the script for browser usage. ```javascript // node js const LuckyCase = require('lucky-case/string'); ``` ```html // browser ``` -------------------------------- ### String.prototype.toUpperWordCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to UPPER WORD CASE. ```APIDOC ## String.prototype.toUpperWordCase(preserve_prefixed_underscores) ### Description Convert string to UPPER WORD CASE. ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines whether to preserve prefixed underscores during conversion. ### Returns - **string** - The UPPER WORD CASE version of the string. ``` -------------------------------- ### string.isTrainCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if a string is in train case. It can optionally allow prefixed underscores. ```APIDOC ## string.isTrainCase(allow_prefixed_underscores) ### Description Check if the string is train case. ### Parameters #### Path Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores are allowed. ### Request Example ```js conversion 'This-Is-An-Example-String' => true ``` ``` -------------------------------- ### LuckyCase.toTrainCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a given string from any case into train case. It supports preserving prefixed underscores. ```APIDOC ## LuckyCase.toTrainCase ### Description Converts the input string into train case (e.g., `This-Is-Train-Case`). It can preserve prefixed underscores. ### Method Signature `LuckyCase.toTrainCase(string, preserve_prefixed_underscores)` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Parameters Table | Param | Type | Default | Description | | --- | --- | --- | --- | | string | `string` | | The string to convert. | | preserve_prefixed_underscores | `boolean` | `true` | If true, prefixed underscores will be maintained in the output. | ``` -------------------------------- ### string.constantize Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts a string from any case into PascalCase and casts it into a constant-like format. ```APIDOC ## string.constantize() ### Description Converts the string from any case into PascalCase and formats it as a constant. This method handles conversions from various string formats, including those with dashes, underscores, and slashes, into a single PascalCase string. ### Method N/A (JavaScript method) ### Parameters This method does not accept any parameters. ### Response #### Success Response (string) Returns the string converted to PascalCase. ### Request Example ```js conversion 'this-isAnExample_string' => ThisIsAnExampleString 'this/is_an/example_path' => ThisIsAnExamplePath ``` ### Response Example ```json "ThisIsAnExampleString" ``` ``` -------------------------------- ### LuckyCase.toDashCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a string to dash-case, optionally preserving prefixed underscores. ```APIDOC ## LuckyCase.toDashCase ### Description Converts a string to dash-case, optionally preserving prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to convert. * `preserve_prefixed_underscores` (boolean) - Whether to preserve prefixed underscores. ### Returns `string` - The dash-case version of the string. ``` -------------------------------- ### LuckyCase.getVersion Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Retrieves the current version of the Lucky Case library. ```APIDOC ## LuckyCase.getVersion() ### Description Get the version of the used library. ### Method GET ### Endpoint /version ### Response #### Success Response (200) - **version** (string) - The version of the library. ``` -------------------------------- ### LuckyCase.toPascalCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a string to PascalCase, optionally preserving prefixed underscores. ```APIDOC ## LuckyCase.toPascalCase ### Description Converts a string to PascalCase, optionally preserving prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to convert. * `preserve_prefixed_underscores` (boolean) - Whether to preserve prefixed underscores. ### Returns `string` - The PascalCase version of the string. ``` -------------------------------- ### String.prototype.toLowerCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the entire string to lowercase. ```APIDOC ## String.prototype.toLowerCase() ### Description Convert string to lower case. ### Returns - **string** - The lowercase version of the string. ``` -------------------------------- ### String.prototype.swapCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Swaps the case of each letter in the string (uppercase to lowercase and vice versa). ```APIDOC ## String.prototype.swapCase(preserve_prefixed_underscores) ### Description Swap the case of each letter in the string. ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines whether to preserve prefixed underscores during the case swap. ### Returns - **string** - The string with its letter cases swapped. ``` -------------------------------- ### LuckyCase.toSentenceCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a string to Sentence case, optionally preserving prefixed underscores. ```APIDOC ## LuckyCase.toSentenceCase ### Description Converts a string to Sentence case, optionally preserving prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to convert. * `preserve_prefixed_underscores` (boolean) - Whether to preserve prefixed underscores. ### Returns `string` - The Sentence case version of the string. ``` -------------------------------- ### Convert to Pascal Case Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a string from any case to pascal case. The `preserve_prefixed_underscores` parameter defaults to true. ```javascript conversion 'this-isAnExample_string' => 'ThisIsAnExampleString' ``` -------------------------------- ### String.prototype.isMixedCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if the string conforms to a mixed case format. ```APIDOC ## String.prototype.isMixedCase(allow_prefixed_underscores) ### Description Check if string is mixed case. ### Parameters #### Query Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be considered when checking for mixed case. ### Returns - **boolean** - True if the string is in mixed case format, false otherwise. ``` -------------------------------- ### LuckyCase.toUpperDashCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a string to UPPER-DASH-CASE, optionally preserving prefixed underscores. ```APIDOC ## LuckyCase.toUpperDashCase ### Description Converts a string to UPPER-DASH-CASE, optionally preserving prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to convert. * `preserve_prefixed_underscores` (boolean) - Whether to preserve prefixed underscores. ### Returns `string` - The UPPER-DASH-CASE version of the string. ``` -------------------------------- ### string.decapitalize Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the first character of a string to lowercase. It can optionally ignore leading underscores. ```APIDOC ## string.decapitalize(skip_prefixed_underscores) ### Description Converts the first character of a string to lowercase. This method can optionally skip checking if the string starts with one or more underscores. ### Method N/A (JavaScript method) ### Parameters #### Query Parameters - **skip_prefixed_underscores** (boolean) - Optional - Defaults to `false`. If true, leading underscores are ignored before converting the first character to lowercase. ### Response #### Success Response (string) Returns the modified string with its first character converted to lowercase (considering `skip_prefixed_underscores`). ### Response Example ```json "lowerCaseString" ``` ``` -------------------------------- ### string.isSentenceCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if a string is in sentence case. It can optionally allow prefixed underscores. ```APIDOC ## string.isSentenceCase(allow_prefixed_underscores) ### Description Check if the string is sentence case. ### Parameters #### Path Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores are allowed. ### Request Example ```js conversion 'This is an example string' => true ``` ``` -------------------------------- ### LuckyCase.capitalize Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Alias for `toCapital`. Capitalizes the first letter of a string, optionally skipping prefixed underscores. ```APIDOC ## LuckyCase.capitalize ### Description Alias for `toCapital`. Capitalizes the first letter of a string, optionally skipping prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to capitalize. * `skip_prefixed_underscores` (boolean) - Whether to skip prefixed underscores when capitalizing. ### Returns `string` - The string with its first letter capitalized. ``` -------------------------------- ### string.isValidCaseString Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if the string conforms to any of the available case formats. ```APIDOC ## string.isValidCaseString() ### Description Check if the string matches any of the available cases ### Returns - boolean ``` -------------------------------- ### LuckyCase.toUpperCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a string to uppercase. ```APIDOC ## LuckyCase.toUpperCase ### Description Converts a string to uppercase. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to convert. ### Returns `string` - The uppercase version of the string. ``` -------------------------------- ### string.convertCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts a string to a specified case type, with an option to preserve prefixed underscores. ```APIDOC ## string.convertCase(case_type, preserve_prefixed_underscores) ### Description Convert a string into the given case type ### Parameters #### Query Parameters - **case_type** (string) - Required - Can be UPPER_CASE or lower_case, e.g. 'SNAKE_CASE' or 'snake_case' - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true` ### Returns - string ``` -------------------------------- ### string.isDashCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if the string is in dash-case format, with an option to allow prefixed underscores. ```APIDOC ## string.isDashCase(allow_prefixed_underscores) ### Description Check if the string is dash case ### Parameters #### Query Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true` ### Returns - boolean ``` -------------------------------- ### LuckyCase.toCamelCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a string to camelCase, optionally preserving prefixed underscores. ```APIDOC ## LuckyCase.toCamelCase ### Description Converts a string to camelCase, optionally preserving prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to convert. * `preserve_prefixed_underscores` (boolean) - Whether to preserve prefixed underscores. ### Returns `string` - The camelCase version of the string. ``` -------------------------------- ### LuckyCase.isTrainCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Checks if a string is in Train-Case format, optionally allowing prefixed underscores. ```APIDOC ## LuckyCase.isTrainCase ### Description Checks if a string is in Train-Case format, optionally allowing prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to check. * `allow_prefixed_underscores` (boolean) - Whether to allow prefixed underscores. ### Returns `boolean` - True if the string is in Train-Case format, false otherwise. ``` -------------------------------- ### string.isPascalCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if the string is in PascalCase format, with an option to allow prefixed underscores. ```APIDOC ## string.isPascalCase(allow_prefixed_underscores) ### Description Check if the string is upper pascal case ### Parameters #### Query Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true` ### Returns - boolean ``` -------------------------------- ### LuckyCase.toWordCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a string to Word Case, optionally preserving prefixed underscores. ```APIDOC ## LuckyCase.toWordCase ### Description Converts a string to Word Case, optionally preserving prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to convert. * `preserve_prefixed_underscores` (boolean) - Whether to preserve prefixed underscores. ### Returns `string` - The Word Case version of the string. ``` -------------------------------- ### String.prototype.isUpperDashCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if the string is in UPPER-DASH-CASE format. ```APIDOC ## String.prototype.isUpperDashCase(allow_prefixed_underscores) ### Description Check if string is UPPER-DASH-CASE. ### Parameters #### Query Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be considered when checking for UPPER-DASH-CASE. ### Returns - **boolean** - True if the string is in UPPER-DASH-CASE format, false otherwise. ``` -------------------------------- ### string.isWordCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if a string is in word case. It can optionally allow prefixed underscores. ```APIDOC ## string.isWordCase(allow_prefixed_underscores) ### Description Check if the string is word case. ### Parameters #### Path Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores are allowed. ### Request Example ```js conversion 'this is an example string' => true ``` ``` -------------------------------- ### string.toSnakeCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to snake_case, with an option to preserve prefixed underscores. ```APIDOC ## string.toSnakeCase(preserve_prefixed_underscores) ### Description Convert the string from any case into snake case ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true` ### Example ```js conversion 'this-isAnExample_string' => 'this_is_an_example_string' ``` ### Returns - string ``` -------------------------------- ### string.isCamelCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if the string is in camelCase format, with an option to allow prefixed underscores. ```APIDOC ## string.isCamelCase(allow_prefixed_underscores) ### Description Check if the string is camel case ### Parameters #### Query Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true` ### Returns - boolean ``` -------------------------------- ### string.isMixedCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if a string is in a valid mixed case format, optionally allowing leading underscores. ```APIDOC ## string.isMixedCase(allow_prefixed_underscores) ### Description Checks if the string is a valid mixed case format. Special characters are not allowed. Leading underscores can be optionally allowed. ### Method N/A (JavaScript method) ### Parameters #### Query Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true`. If true, leading underscores are permitted in the mixed case string. ### Response #### Success Response (boolean) Returns `true` if the string is in a valid mixed case format, `false` otherwise. ### Response Example ```json true ``` ``` -------------------------------- ### LuckyCase.toCapitalWordCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a string to Capital Word Case, optionally preserving prefixed underscores. ```APIDOC ## LuckyCase.toCapitalWordCase ### Description Converts a string to Capital Word Case, optionally preserving prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to convert. * `preserve_prefixed_underscores` (boolean) - Whether to preserve prefixed underscores. ### Returns `string` - The Capital Word Case version of the string. ``` -------------------------------- ### Convert to Train Case Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a string from any case to train case. The `preserve_prefixed_underscores` parameter defaults to true. ```javascript conversion 'this-isAnExample_string' => 'This-Is-An-Example-String' ``` -------------------------------- ### LuckyCase.toCapital Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Capitalizes the first letter of a string, optionally skipping prefixed underscores. ```APIDOC ## LuckyCase.toCapital ### Description Capitalizes the first letter of a string, optionally skipping prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to capitalize. * `skip_prefixed_underscores` (boolean) - Whether to skip prefixed underscores when capitalizing. ### Returns `string` - The string with its first letter capitalized. ``` -------------------------------- ### String.prototype.isNotCapital Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if the first letter of the string is not capitalized. ```APIDOC ## String.prototype.isNotCapital(skip_prefixed_underscores) ### Description Check if the first letter of the string is not capitalized. ### Parameters #### Query Parameters - **skip_prefixed_underscores** (boolean) - Optional - Defaults to `false`. Determines whether to skip the check if the string starts with prefixed underscores. ### Returns - **boolean** - True if the first letter is not capitalized, false otherwise. ``` -------------------------------- ### LuckyCase.swapCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Swaps the case of each letter in a string, optionally preserving prefixed underscores. ```APIDOC ## LuckyCase.swapCase ### Description Swaps the case of each letter in a string, optionally preserving prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to swap cases. * `preserve_prefixed_underscores` (boolean) - Whether to preserve prefixed underscores. ### Returns `string` - The string with its letter cases swapped. ``` -------------------------------- ### String.prototype.isSnakeCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if the string is in snake_case format. ```APIDOC ## String.prototype.isSnakeCase(allow_prefixed_underscores) ### Description Check if string is snake_case. ### Parameters #### Query Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be considered when checking for snake_case. ### Returns - **boolean** - True if the string is in snake_case format, false otherwise. ``` -------------------------------- ### String.prototype.toMixedCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to a mixed case format. The exact format may depend on the library's internal logic for 'mixed case'. ```APIDOC ## String.prototype.toMixedCase(preserve_prefixed_underscores) ### Description Convert string to mixed case. ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines whether to preserve prefixed underscores during conversion. ### Returns - **string** - The mixed case version of the string. ``` -------------------------------- ### String.prototype.isDashCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Checks if the string is in dash-case format. ```APIDOC ## String.prototype.isDashCase(allow_prefixed_underscores) ### Description Check if string is dash-case. ### Parameters #### Query Parameters - **allow_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines if prefixed underscores should be considered when checking for dash-case. ### Returns - **boolean** - True if the string is in dash-case format, false otherwise. ``` -------------------------------- ### LuckyCase.isSentenceCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Checks if a string is in Sentence case format, optionally allowing prefixed underscores. ```APIDOC ## LuckyCase.isSentenceCase ### Description Checks if a string is in Sentence case format, optionally allowing prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to check. * `allow_prefixed_underscores` (boolean) - Whether to allow prefixed underscores. ### Returns `boolean` - True if the string is in Sentence case format, false otherwise. ``` -------------------------------- ### string.toMixedCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts a string from any case into mixed case, ensuring the output is different from the input. It can optionally preserve leading underscores. ```APIDOC ## string.toMixedCase(preserve_prefixed_underscores) ### Description Converts the string from any case into mixed case. The new string is ensured to be different from the input. Leading underscores can be preserved. ### Method N/A (JavaScript method) ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `false`. If true, leading underscores are preserved in the output string. ### Response #### Success Response (string) Returns the string converted to mixed case. ### Request Example ```js "this-isAnExample_string" => "This-Is_anExample-string" ``` ### Response Example ```json "This-Is_anExample-string" ``` ``` -------------------------------- ### string.swapCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Swaps the case of characters in a string (lowercase to uppercase, uppercase to lowercase) and also swaps dashes and underscores. It can optionally preserve leading underscores. ```APIDOC ## string.swapCase(preserve_prefixed_underscores) ### Description Swaps character cases in the string. Lowercase characters are converted to uppercase, and uppercase characters are converted to lowercase. Additionally, dashes are converted to underscores, and underscores are converted to dashes. Leading underscores can be preserved. ### Method N/A (JavaScript method) ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `false`. If true, leading underscores are preserved in the output string. ### Response #### Success Response (string) Returns the string with swapped character cases and swapped dashes/underscores. ### Request Example ```js conversion 'this-isAnExample_string' => 'THIS_ISaNeXAMPLE-STRING' ``` ### Response Example ```json "THIS_ISaNeXAMPLE-STRING" ``` ``` -------------------------------- ### LuckyCase.toMixedCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case.jsdoc.md Converts a string to a mixed case format, optionally preserving prefixed underscores. ```APIDOC ## LuckyCase.toMixedCase ### Description Converts a string to a mixed case format, optionally preserving prefixed underscores. ### Method N/A (Static method) ### Parameters #### Arguments * `string` (string) - The input string to convert. * `preserve_prefixed_underscores` (boolean) - Whether to preserve prefixed underscores. ### Returns `string` - The mixed case version of the string. ``` -------------------------------- ### String.prototype.toSnakeCase Source: https://github.com/magynhard/lucky-case/blob/master/doc/lucky-case-string.jsdoc.md Converts the string to snake_case. ```APIDOC ## String.prototype.toSnakeCase(preserve_prefixed_underscores) ### Description Convert string to snake_case. ### Parameters #### Query Parameters - **preserve_prefixed_underscores** (boolean) - Optional - Defaults to `true`. Determines whether to preserve prefixed underscores during conversion. ### Returns - **string** - The snake_case version of the string. ```