Convert API

toSnake()

Converts the passed arguments to "snake_case" format.

  • Accepts arguments as strings and arrays of strings.
    Each value is seen as a new argument.
  • Returns the converted string if a single argument is passed and an array of strings if multiple arguments are passed.
Example:
toSnake('fontSize');
// 'font_size'

toSnake(['fontSize']);
// 'font_size'

toSnake('border-radius', 'border_color', 'borderStyle');
// ['border_radius', 'border_color', 'border_style']

toSnake(['borderRadius', 'border-color']);
// ['border_radius', 'border_color']

toSnake('font-size', ['borderRadius', 'border_color']);
// ['font_size', 'border_radius', 'border_color']

toSnake('fontSize: 10px, border-radius: 10px');
// 'font_size: 10px, border_radius: 10px'