forked from siddii/angular-timer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzip.js
More file actions
29 lines (23 loc) · 675 Bytes
/
zip.js
File metadata and controls
29 lines (23 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var max = require('./max');
var pluck = require('./pluck');
var map = require('./map');
function getLength(arr) {
return arr == null ? 0 : arr.length;
}
/**
* Merges together the values of each of the arrays with the values at the
* corresponding position.
*/
function zip(arr){
var len = arr ? max(map(arguments, getLength)) : 0,
results = [],
i = -1,
item;
while (++i < len) {
results.push(map(arguments, function(item) {
return item == null ? undefined : item[i];
}));
}
return results;
}
module.exports = zip;