• Converts a string to a slug format, replacing spaces with hyphens and removing special characters.

    Example

    toSlug("Bread And Butter")
    // => { ok: true, value: 'bread-and-butter' }

    Example

    Handling non-string input:

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

    Parameters

    • str: string

      The string to convert to a slug format.

    Returns Result<string, Error>

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

Generated using TypeDoc v0.24.7