1 | /*!
|
2 | * repeat-string <https://github.com/jonschlinkert/repeat-string>
|
3 | *
|
4 | * Copyright (c) 2014-2015 Jon Schlinkert, contributors.
|
5 | * Licensed under the MIT License
|
6 | */
|
7 |
|
8 | ;
|
9 |
|
10 | module.exports = function repeat(str, num) {
|
11 | if (typeof str !== 'string') {
|
12 | throw new TypeError('repeat-string expects a string.');
|
13 | }
|
14 |
|
15 | var res = '';
|
16 |
|
17 | while (num) {
|
18 | if (num & 1) {
|
19 | res += str;
|
20 | }
|
21 | num >>= 1;
|
22 | str += str;
|
23 | }
|
24 |
|
25 | return res;
|
26 | };
|