8bce9c075fefa31a517a22de1a5625d4257715b0
[platform/framework/web/crosswalk-tizen.git] /
1 var max = require('./max');
2 var map = require('./map');
3
4     function getLength(arr) {
5         return arr == null ? 0 : arr.length;
6     }
7
8     /**
9      * Merges together the values of each of the arrays with the values at the
10      * corresponding position.
11      */
12     function zip(arr){
13         var len = arr ? max(map(arguments, getLength)) : 0,
14             results = [],
15             i = -1;
16         while (++i < len) {
17             // jshint loopfunc: true
18             results.push(map(arguments, function(item) {
19                 return item == null ? undefined : item[i];
20             }));
21         }
22
23         return results;
24     }
25
26     module.exports = zip;
27
28