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.

repeat.js 893B

12345678910111213141516171819202122232425262728293031323334353637
  1. var baseRepeat = require('./_baseRepeat'),
  2. isIterateeCall = require('./_isIterateeCall'),
  3. toInteger = require('./toInteger'),
  4. toString = require('./toString');
  5. /**
  6. * Repeats the given string `n` times.
  7. *
  8. * @static
  9. * @memberOf _
  10. * @since 3.0.0
  11. * @category String
  12. * @param {string} [string=''] The string to repeat.
  13. * @param {number} [n=1] The number of times to repeat the string.
  14. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  15. * @returns {string} Returns the repeated string.
  16. * @example
  17. *
  18. * _.repeat('*', 3);
  19. * // => '***'
  20. *
  21. * _.repeat('abc', 2);
  22. * // => 'abcabc'
  23. *
  24. * _.repeat('abc', 0);
  25. * // => ''
  26. */
  27. function repeat(string, n, guard) {
  28. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  29. n = 1;
  30. } else {
  31. n = toInteger(n);
  32. }
  33. return baseRepeat(toString(string), n);
  34. }
  35. module.exports = repeat;