Function getHexValue

  • Extracts the hexadecimal value from a string that starts with a "#" character.

    Example

    getHexValue("#ff00ff")
    // => { ok: true, value: 'ff00ff' }

    Example

    Handle invalid input:

    getHexValue("ff0000")
    // => { ok: false, error: Error('[colors.getHexValue] Expected a valid hex string') }

    Parameters

    • str: string

      The string to extract the hexadecimal value from.

    Returns Result<string, Error>

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

Generated using TypeDoc v0.24.7