1 /** Used as references for various `Number` constants. */
2 var MAX_SAFE_INTEGER = 9007199254740991;
4 /* Built-in method references for those with the same name as other `lodash` methods. */
5 var nativeFloor = Math.floor;
8 * The base implementation of `_.repeat` which doesn't coerce arguments.
11 * @param {string} string The string to repeat.
12 * @param {number} n The number of times to repeat the string.
13 * @returns {string} Returns the repeated string.
15 function baseRepeat(string, n) {
17 if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
20 // Leverage the exponentiation by squaring algorithm for a faster repeat.
21 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
26 n = nativeFloor(n / 2);
35 module.exports = baseRepeat;