Ohm-Management - Projektarbeit B-ME
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.

_createCaseFirst.js 811B

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