2 var toInteger = require('../internals/to-integer');
3 var requireObjectCoercible = require('../internals/require-object-coercible');
5 // `String.prototype.repeat` method implementation
6 // https://tc39.es/ecma262/#sec-string.prototype.repeat
7 module.exports = ''.repeat || function repeat(count) {
8 var str = String(requireObjectCoercible(this));
10 var n = toInteger(count);
11 if (n < 0 || n == Infinity) throw RangeError('Wrong number of repetitions');
12 for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;