1 var stringToArray = require('./_stringToArray'),
2 toString = require('./toString');
4 /** Used to compose unicode character classes. */
5 var rsAstralRange = '\\ud800-\\udfff',
6 rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
7 rsComboSymbolsRange = '\\u20d0-\\u20f0',
8 rsVarRange = '\\ufe0e\\ufe0f';
10 /** Used to compose unicode capture groups. */
11 var rsZWJ = '\\u200d';
13 /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
14 var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
17 * Creates a function like `_.lowerFirst`.
20 * @param {string} methodName The name of the `String` case method to use.
21 * @returns {Function} Returns the new function.
23 function createCaseFirst(methodName) {
24 return function(string) {
25 string = toString(string);
27 var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined,
28 chr = strSymbols ? strSymbols[0] : string.charAt(0),
29 trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
31 return chr[methodName]() + trailing;
35 module.exports = createCaseFirst;