jj
    Preparing search index...

    Function pas2keb

    • Converts a PascalCase, camelCase, or snake_case string to kebab-case.

      Parameters

      • str: string

        The string to convert.

      Returns string

      The kebab-case string.

      This function is useful for converting JavaScript property names to CSS or HTML attribute names. It strictly validates the input to contain only alphanumeric characters and underscores.

      pas2keb('backgroundColor') // 'background-color'
      pas2keb('MyComponent') // 'my-component'
      pas2keb('user_id') // 'user-id'

      If str is not a string or contains invalid characters (anything other than /[a-zA-Z0-9_]/).