Collection of convenience code snippets (helpers) that aims to make it a little easier to work with vanilla JS
vanillajs-helpers > “camelCase”
Τ CamelCaseFunction: function
Defined in camelCase.ts:11
►(str: string
): string
Parameters:
Param | Type | Description |
---|---|---|
str | string |
- |
Returns: string
► camelCase(input?: CamelCaseSettings): CamelCaseFunction
► camelCase(input: string
): string
Defined in camelCase.ts:60
Return a function that transforms a string into a camelCased word (eg. ‘camel case’ -> ‘camelCase’).
const caser = camelCase({ abbr: true, numbers: true, upper: true });
caser('data-VALUE2-input'); // -> DataVALUE2Input
caser('XML data input'); // -> XMLDataInput
Parameters:
Param | Type | Description |
---|---|---|
input | CamelCaseSettings | The settings for the returned format method |
Returns: CamelCaseFunction
Defined in camelCase.ts:80
Transform a string into a camelCased word (eg. ‘camel case’ -> ‘camelCase’)
camelCase('data-value2-input'); // -> dataValue2input
camelCase('XML data input'); // -> XmlDataInput
The Ruels of the camel casing can be changed by giving it an object
const camelCaseKeepAbbr = camelCase({ abbr: true });
camelCaseKeepAbbr('XML data input'); // -> XMLDataInput
Parameters:
Param | Type | Description |
---|---|---|
input | string |
The string to format |
Returns: string
► caser(settings: CamelCaseSettings, str: string
): string
Defined in camelCase.ts:33
Transform a string into a camelCased word (eg. ‘camel case’ -> ‘camelCase’)
caser('data-value2-input'); // -> dataValue2input
Parameters:
Param | Type | Description |
---|---|---|
settings | CamelCaseSettings | The settings for the string formatting |
str | string |
The string to format |
Returns: string
● abbr: false
= false
Defined in camelCase.ts:17
● numbers: true
= true
Defined in camelCase.ts:18
● upper: false
= false
Defined in camelCase.ts:16