mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
31 lines
710 B
JavaScript
31 lines
710 B
JavaScript
import words from './words.js'
|
|
|
|
const reQuotes = /['\u2019]/g
|
|
|
|
/**
|
|
* Converts `string`, as space separated words, to lower case.
|
|
*
|
|
* @since 4.0.0
|
|
* @category String
|
|
* @param {string} [string=''] The string to convert.
|
|
* @returns {string} Returns the lower cased string.
|
|
* @see camelCase, kebabCase, snakeCase, startCase, upperCase, upperFirst
|
|
* @example
|
|
*
|
|
* lowerCase('--Foo-Bar--')
|
|
* // => 'foo bar'
|
|
*
|
|
* lowerCase('fooBar')
|
|
* // => 'foo bar'
|
|
*
|
|
* lowerCase('__FOO_BAR__')
|
|
* // => 'foo bar'
|
|
*/
|
|
const lowerCase = (string) => (
|
|
words(`${string}`.replace(reQuotes, '')).reduce((result, word, index) => (
|
|
result + (index ? ' ' : '') + word.toLowerCase()
|
|
), '')
|
|
)
|
|
|
|
export default lowerCase
|