a4cc282d3ce7227c5057307c6e2e1e51562ed1b1
[platform/framework/web/crosswalk-tizen.git] /
1 define(['../lang/toString', './WHITE_SPACES'], function(toString, WHITE_SPACES){
2     /**
3      * Remove chars from end of string.
4      */
5     function rtrim(str, chars) {
6         str = toString(str);
7         chars = chars || WHITE_SPACES;
8
9         var end = str.length - 1,
10             charLen = chars.length,
11             found = true,
12             i, c;
13
14         while (found && end >= 0) {
15             found = false;
16             i = -1;
17             c = str.charAt(end);
18
19             while (++i < charLen) {
20                 if (c === chars[i]) {
21                     found = true;
22                     end--;
23                     break;
24                 }
25             }
26         }
27
28         return (end >= 0) ? str.substring(0, end + 1) : '';
29     }
30
31     return rtrim;
32 });