mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Remove createCompounder.
This commit is contained in:
@@ -1,19 +0,0 @@
|
|||||||
import words from '../words.js'
|
|
||||||
|
|
||||||
/** Used to match apostrophes. */
|
|
||||||
const reApos = /['\u2019]/g
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a function like `camelCase`.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Function} callback The function to combine each word.
|
|
||||||
* @returns {Function} Returns the new compounder function.
|
|
||||||
*/
|
|
||||||
function createCompounder(callback) {
|
|
||||||
return (string) => (
|
|
||||||
words(`${ string }`.replace(reApos, '')).reduce(callback, '')
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default createCompounder
|
|
||||||
12
camelCase.js
12
camelCase.js
@@ -1,5 +1,5 @@
|
|||||||
import capitalize from './capitalize.js'
|
import capitalize from './capitalize.js'
|
||||||
import createCompounder from './.internal/createCompounder.js'
|
import words from './words.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
|
* Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
|
||||||
@@ -20,9 +20,11 @@ import createCompounder from './.internal/createCompounder.js'
|
|||||||
* camelCase('__FOO_BAR__')
|
* camelCase('__FOO_BAR__')
|
||||||
* // => 'fooBar'
|
* // => 'fooBar'
|
||||||
*/
|
*/
|
||||||
const camelCase = createCompounder((result, word, index) => {
|
const camelCase = (string) => (
|
||||||
word = word.toLowerCase()
|
words(`${ string }`.replace(/['\u2019]/g, '')).reduce((result, word, index) => {
|
||||||
return result + (index ? capitalize(word) : word)
|
word = word.toLowerCase()
|
||||||
})
|
return result + (index ? capitalize(word) : word)
|
||||||
|
}, '')
|
||||||
|
)
|
||||||
|
|
||||||
export default camelCase
|
export default camelCase
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import createCompounder from './.internal/createCompounder.js'
|
import words from './words.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `string` to
|
* Converts `string` to
|
||||||
@@ -20,8 +20,10 @@ import createCompounder from './.internal/createCompounder.js'
|
|||||||
* kebabCase('__FOO_BAR__')
|
* kebabCase('__FOO_BAR__')
|
||||||
* // => 'foo-bar'
|
* // => 'foo-bar'
|
||||||
*/
|
*/
|
||||||
const kebabCase = createCompounder((result, word, index) =>
|
const kebabCase = (string) => (
|
||||||
result + (index ? '-' : '') + word.toLowerCase()
|
words(`${ string }`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
|
||||||
|
result + (index ? '-' : '') + word.toLowerCase()
|
||||||
|
), '')
|
||||||
)
|
)
|
||||||
|
|
||||||
export default kebabCase
|
export default kebabCase
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import createCompounder from './.internal/createCompounder.js'
|
import words from './words.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `string`, as space separated words, to lower case.
|
* Converts `string`, as space separated words, to lower case.
|
||||||
@@ -19,8 +19,10 @@ import createCompounder from './.internal/createCompounder.js'
|
|||||||
* lowerCase('__FOO_BAR__')
|
* lowerCase('__FOO_BAR__')
|
||||||
* // => 'foo bar'
|
* // => 'foo bar'
|
||||||
*/
|
*/
|
||||||
const lowerCase = createCompounder((result, word, index) =>
|
const lowerCase = (string) => (
|
||||||
result + (index ? ' ' : '') + word.toLowerCase()
|
words(`${ string }`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
|
||||||
|
result + (index ? ' ' : '') + word.toLowerCase()
|
||||||
|
), '')
|
||||||
)
|
)
|
||||||
|
|
||||||
export default lowerCase
|
export default lowerCase
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import createCompounder from './.internal/createCompounder.js'
|
import words from './words.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `string` to
|
* Converts `string` to
|
||||||
@@ -20,8 +20,10 @@ import createCompounder from './.internal/createCompounder.js'
|
|||||||
* snakeCase('--FOO-BAR--')
|
* snakeCase('--FOO-BAR--')
|
||||||
* // => 'foo_bar'
|
* // => 'foo_bar'
|
||||||
*/
|
*/
|
||||||
const snakeCase = createCompounder((result, word, index) =>
|
const snakeCase = (string) => (
|
||||||
result + (index ? '_' : '') + word.toLowerCase()
|
words(`${ string }`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
|
||||||
|
result + (index ? '_' : '') + word.toLowerCase()
|
||||||
|
), '')
|
||||||
)
|
)
|
||||||
|
|
||||||
export default snakeCase
|
export default snakeCase
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import createCompounder from './.internal/createCompounder.js'
|
|
||||||
import upperFirst from './upperFirst.js'
|
import upperFirst from './upperFirst.js'
|
||||||
|
import words from './words.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `string` to
|
* Converts `string` to
|
||||||
@@ -21,8 +21,10 @@ import upperFirst from './upperFirst.js'
|
|||||||
* startCase('__FOO_BAR__')
|
* startCase('__FOO_BAR__')
|
||||||
* // => 'FOO BAR'
|
* // => 'FOO BAR'
|
||||||
*/
|
*/
|
||||||
const startCase = createCompounder((result, word, index) =>
|
const startCase = (string) => (
|
||||||
result + (index ? ' ' : '') + upperFirst(word)
|
words(`${ string }`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
|
||||||
|
result + (index ? ' ' : '') + upperFirst(word)
|
||||||
|
), '')
|
||||||
)
|
)
|
||||||
|
|
||||||
export default startCase
|
export default startCase
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import createCompounder from './.internal/createCompounder.js'
|
import words from './words.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `string`, as space separated words, to upper case.
|
* Converts `string`, as space separated words, to upper case.
|
||||||
@@ -19,8 +19,10 @@ import createCompounder from './.internal/createCompounder.js'
|
|||||||
* upperCase('__foo_bar__')
|
* upperCase('__foo_bar__')
|
||||||
* // => 'FOO BAR'
|
* // => 'FOO BAR'
|
||||||
*/
|
*/
|
||||||
const upperCase = createCompounder((result, word, index) =>
|
const upperCase = (string) => (
|
||||||
result + (index ? ' ' : '') + word.toUpperCase()
|
words(`${ string }`.replace(/['\u2019]/g, '')).reduce((result, word, index) => (
|
||||||
|
result + (index ? ' ' : '') + word.toUpperCase()
|
||||||
|
), '')
|
||||||
)
|
)
|
||||||
|
|
||||||
export default upperCase
|
export default upperCase
|
||||||
|
|||||||
Reference in New Issue
Block a user