1 var baseToString = require('../internal/baseToString');
3 /** Native method references. */
4 var floor = Math.floor;
6 /* Native method references for those with the same name as other `lodash` methods. */
7 var nativeIsFinite = global.isFinite;
10 * Repeats the given string `n` times.
15 * @param {string} [string=''] The string to repeat.
16 * @param {number} [n=0] The number of times to repeat the string.
17 * @returns {string} Returns the repeated string.
29 function repeat(string, n) {
31 string = baseToString(string);
33 if (n < 1 || !string || !nativeIsFinite(n)) {
36 // Leverage the exponentiation by squaring algorithm for a faster repeat.
37 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
49 module.exports = repeat;