• Converts a string to snake_case.

    Remarks

    This function converts a string to kebab-case, which is a naming convention where multiple words are joined together with underscores (_) and all characters are lowercase.

    Example

    Converting a string with spaces to snake_case:

    toSnakeCase('hello world')
    // => { ok: true, value: 'hello_world' }

    Example

    Converting a string with hyphens to snake_case:

    toSnakeCase('fooBarBaz')
    // => { ok: true, value: 'foo_bar_baz' }

    Example

    Handling non-string input:

    toSnakeCase(42)
    // => { ok: false, error: Error('[strings.toSnakeCase] Expected string value as input') }

    Parameters

    • str: string

      The input string to convert.

    Returns Result<string, Error>

    A Result containing the converted string on success, or an Error object if the provided input is not a string.

Generated using TypeDoc v0.24.7