source: imaps-frontend/node_modules/lodash-es/_createCaseFirst.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 809 bytes
RevLine 
[d565449]1import castSlice from './_castSlice.js';
2import hasUnicode from './_hasUnicode.js';
3import stringToArray from './_stringToArray.js';
4import toString from './toString.js';
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 */
13function 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
33export default createCaseFirst;
Note: See TracBrowser for help on using the repository browser.