Converts a string to camelCase.
This function converts a string to camelCase, which is a naming convention where multiple words are joined together and the first letter of each subsequent word is capitalized, except for the first word.
Converting a string with spaces to camelCase:
toCamelCase('hello world')// => { ok: true, value: 'helloWorld' } Copy
toCamelCase('hello world')// => { ok: true, value: 'helloWorld' }
Converting a string with hyphens to camelCase:
toCamelCase('foo-bar-baz')// => { ok: true, value: 'fooBarBaz' } Copy
toCamelCase('foo-bar-baz')// => { ok: true, value: 'fooBarBaz' }
Handling non-string input:
toCamelCase(42)// => { ok: false, error: Error('[strings.toCamelCase] Expected string value as input') } Copy
toCamelCase(42)// => { ok: false, error: Error('[strings.toCamelCase] Expected string value as input') }
The input string to convert.
A Result containing the converted string on success, or an Error object if the provided input is not a string.
Result
Error
Generated using TypeDoc v0.24.7
Converts a string to camelCase.
Remarks
This function converts a string to camelCase, which is a naming convention where multiple words are joined together and the first letter of each subsequent word is capitalized, except for the first word.
Example
Converting a string with spaces to camelCase:
Example
Converting a string with hyphens to camelCase:
Example
Handling non-string input: