• Normalizes a string by replacing non-word characters with a space character.

    Example

    normalize('Hello_World!123')
    // => { ok: true, value: 'Hello World 123' }
    // => Hello World 123

    normalize('This is a sample string.')
    // => { ok: true, value: 'This is a sample string' }

    Example

    Returns the default if there is an error:

    normalize(10).unwrapOr('')
    // => ''

    Example

    Handling non-string input:

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

    Parameters

    • str: string

      The string normalize.

    Returns Result<string, Error>

    A Result object with either the normalized string on success, or an Error object if the provided input is not a string.

Generated using TypeDoc v0.24.7