1 |
3a515b92
|
cagy
|
var castSlice = require('./_castSlice'),
|
2 |
|
|
hasUnicode = require('./_hasUnicode'),
|
3 |
|
|
stringToArray = require('./_stringToArray'),
|
4 |
|
|
toString = require('./toString');
|
5 |
|
|
|
6 |
|
|
/**
|
7 |
|
|
* Creates a function like `_.lowerFirst`.
|
8 |
|
|
*
|
9 |
|
|
* @private
|
10 |
|
|
* @param {string} methodName The name of the `String` case method to use.
|
11 |
|
|
* @returns {Function} Returns the new case function.
|
12 |
|
|
*/
|
13 |
|
|
function createCaseFirst(methodName) {
|
14 |
|
|
return function(string) {
|
15 |
|
|
string = toString(string);
|
16 |
|
|
|
17 |
|
|
var strSymbols = hasUnicode(string)
|
18 |
|
|
? stringToArray(string)
|
19 |
|
|
: undefined;
|
20 |
|
|
|
21 |
|
|
var chr = strSymbols
|
22 |
|
|
? strSymbols[0]
|
23 |
|
|
: string.charAt(0);
|
24 |
|
|
|
25 |
|
|
var trailing = strSymbols
|
26 |
|
|
? castSlice(strSymbols, 1).join('')
|
27 |
|
|
: string.slice(1);
|
28 |
|
|
|
29 |
|
|
return chr[methodName]() + trailing;
|
30 |
|
|
};
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
module.exports = createCaseFirst;
|