994caba11ce517d067ff63c24a4706d573c55de7
[platform/framework/web/crosswalk-tizen.git] /
1 define(function () {
2
3     /**
4      * Create slice of source array or array-like object
5      */
6     function slice(arr, start, end){
7         var len = arr.length;
8
9         if (start == null) {
10             start = 0;
11         } else if (start < 0) {
12             start = Math.max(len + start, 0);
13         } else {
14             start = Math.min(start, len);
15         }
16
17         if (end == null) {
18             end = len;
19         } else if (end < 0) {
20             end = Math.max(len + end, 0);
21         } else {
22             end = Math.min(end, len);
23         }
24
25         var result = [];
26         while (start < end) {
27             result.push(arr[start++]);
28         }
29
30         return result;
31     }
32
33     return slice;
34
35 });