COLLECTED BY
Organization:
Internet Archive
Focused crawls are collections of frequently-updated webcrawl data from narrow (as opposed to broad or wide) web crawls, often focused on a single domain or subdomain.
The Wayback Machine - https://web.archive.org/web/20201220222314/https://github.com/lodash/lodash/blob/master/snakeCase.js
Permalink
Cannot retrieve contributors at this time
33 lines (31 sloc)
789 Bytes
import words from './words.js'
import toString from './toString.js'
/**
* Converts `string` to
* [snake case](https://en.wikipedia.org/wiki/Snake_case).
*
* @since 3.0.0
* @category String
* @param {string } [string=''] The string to convert.
* @returns {string } Returns the snake cased string.
* @see camelCase, lowerCase, kebabCase, startCase, upperCase, upperFirst
* @example
*
* snakeCase('Foo Bar')
* // => 'foo_bar'
*
* snakeCase('fooBar')
* // => 'foo_bar'
*
* snakeCase('--FOO-BAR--')
* // => 'foo_bar'
*
* snakeCase('foo2bar')
* // => 'foo_2_bar'
*/
const snakeCase = ( string ) => (
words ( toString ( string ) . replace ( /[ '\u 2019] /g , '' ) ) . reduce ( ( result , word , index ) => (
result + ( index ? '_' : '' ) + word . toLowerCase ( )
) , '' )
)
export default snakeCase
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.