1 | 'use strict';
|
2 | var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
|
3 | var toString = require('../internals/to-string');
|
4 | var requireObjectCoercible = require('../internals/require-object-coercible');
|
5 |
|
6 | var $RangeError = RangeError;
|
7 |
|
8 |
|
9 |
|
10 | module.exports = function repeat(count) {
|
11 | var str = toString(requireObjectCoercible(this));
|
12 | var result = '';
|
13 | var n = toIntegerOrInfinity(count);
|
14 | if (n < 0 || n === Infinity) throw new $RangeError('Wrong number of repetitions');
|
15 | for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str;
|
16 | return result;
|
17 | };
|