79c45be7b3b5667bc1dd54d4d7bbfb45c39f7711
[platform/framework/web/crosswalk-tizen.git] /
1 define(['../math/clamp', '../lang/toString'], function (clamp, toString) {
2
3     /**
4      * Inserts a string at a given index.
5      */
6     function insert(string, index, partial){
7         string = toString(string);
8
9         if (index < 0) {
10             index = string.length + index;
11         }
12
13         index = clamp(index, 0, string.length);
14
15         return string.substr(0, index) + partial + string.substr(index);
16     }
17
18     return insert;
19
20 });