Function snakeCase

  • Converts a string to snake_case

    Parameters

    • str: string

      string to convert

    • options: {
          screaming: boolean;
      } = ...

      options for the conversion

      • screaming: boolean

    Returns string

    the string in snake_case

    Example

    snakeCase('fooBar') // returns 'foo_bar'
    snakeCase('foo-bar') // returns 'foo_bar'
    snakeCase('foo_bar') // returns 'foo_bar'
    snakeCase('FOO_BAR') // returns 'foo_bar'
    snakeCase('foo') // returns 'foo'
    snakeCase('') // returns ''
    snakeCase('fooBar', { screaming: true }) // returns 'FOO_BAR'
    snakeCase('foo-bar', { screaming: true }) // returns 'FOO_BAR'
    snakeCase('foo_bar', { screaming: true }) // returns 'FOO_BAR'
    snakeCase('FOO_BAR', { screaming: true }) // returns 'FOO_BAR'
    snakeCase('foo', { screaming: true }) // returns 'FOO'
    snakeCase('fooBar', { screaming: true }) // returns 'FOO_BAR'
    snakeCase('foo-bar', { screaming: true }) // returns 'FOO_BAR'

Generated using TypeDoc