0a25d8365ee00e4d9fa84693cc6faa98aba1f088
[platform/framework/web/crosswalk-tizen.git] /
1 define(['../lang/toString', '../number/toInt'], function(toString, toInt){
2
3     /**
4      * Repeat string n times
5      */
6      function repeat(str, n){
7          var result = '';
8          str = toString(str);
9          n = toInt(n);
10         if (n < 1) {
11             return '';
12         }
13         while (n > 0) {
14             if (n % 2) {
15                 result += str;
16             }
17             n = Math.floor(n / 2);
18             str += str;
19         }
20         return result;
21      }
22
23      return repeat;
24
25 });