source: trip-planner-front/node_modules/lodash/repeat.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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