bd8eb071c17ffd21c0f79b525fd75988c4f72bf3
[platform/framework/web/crosswalk-tizen.git] /
1
2
3     /**
4      * Iterates over a callback a set amount of times
5      * returning the results
6      */
7     function take(n, callback, thisObj){
8         var i = -1;
9         var arr = [];
10         if( !thisObj ){
11             while(++i < n){
12                 arr[i] = callback(i, n);
13             }
14         } else {
15             while(++i < n){
16                 arr[i] = callback.call(thisObj, i, n);
17             }
18         }
19         return arr;
20     }
21
22     module.exports = take;
23
24