projects
/
platform
/
framework
/
web
/
crosswalk-tizen.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
df0dc1e5eb1b2dc69108bfe7d6fcb88c9b9a63f0
[platform/framework/web/crosswalk-tizen.git]
/
1
var toString = require('../lang/toString');
2
var toInt = require('../number/toInt');
3
4
/**
5
* Repeat string n times
6
*/
7
function repeat(str, n){
8
var result = '';
9
str = toString(str);
10
n = toInt(n);
11
if (n < 1) {
12
return '';
13
}
14
while (n > 0) {
15
if (n % 2) {
16
result += str;
17
}
18
n = Math.floor(n / 2);
19
str += str;
20
}
21
return result;
22
}
23
24
module.exports = repeat;
25
26