Converts a camelCase string to snake_case.
This function expects a string input and returns a Result object containing either the converted string on success or an error on failure.
Convert a camelCase string to snake_case:
camelToSnake('helloWorld')// => { ok: true, value: 'hello_world' } Copy
camelToSnake('helloWorld')// => { ok: true, value: 'hello_world' }
Handle an invalid input string:
camelToSnake(42);// => { ok: false, error: Error('[strings.camelToSnake] Expected string value as input') } Copy
camelToSnake(42);// => { ok: false, error: Error('[strings.camelToSnake] Expected string value as input') }
The camelCase string to convert.
A Result object containing either the converted string or an Error object if the provided input is not a string.
Result
Error
Generated using TypeDoc v0.24.7
Converts a camelCase string to snake_case.
Remarks
This function expects a string input and returns a Result object containing either the converted string on success or an error on failure.
Example
Convert a camelCase string to snake_case:
Example
Handle an invalid input string: