forked from fdzcxy212206413/gsl_grs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
809 B
34 lines
809 B
1 month ago
|
import castSlice from './_castSlice.js';
|
||
|
import hasUnicode from './_hasUnicode.js';
|
||
|
import stringToArray from './_stringToArray.js';
|
||
|
import toString from './toString.js';
|
||
|
|
||
|
/**
|
||
|
* Creates a function like `_.lowerFirst`.
|
||
|
*
|
||
|
* @private
|
||
|
* @param {string} methodName The name of the `String` case method to use.
|
||
|
* @returns {Function} Returns the new case function.
|
||
|
*/
|
||
|
function createCaseFirst(methodName) {
|
||
|
return function(string) {
|
||
|
string = toString(string);
|
||
|
|
||
|
var strSymbols = hasUnicode(string)
|
||
|
? stringToArray(string)
|
||
|
: undefined;
|
||
|
|
||
|
var chr = strSymbols
|
||
|
? strSymbols[0]
|
||
|
: string.charAt(0);
|
||
|
|
||
|
var trailing = strSymbols
|
||
|
? castSlice(strSymbols, 1).join('')
|
||
|
: string.slice(1);
|
||
|
|
||
|
return chr[methodName]() + trailing;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export default createCaseFirst;
|