徐总多门店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

25 lines
492 B

var pluck = require('./pluck')
var max = require('./max')
/**
* 与 zip 相反
*
* @param {Array} arrays 数组集合
*/
function unzip (arrays) {
var index, maxItem, len
var result = []
if (arrays && arrays.length) {
index = 0
maxItem = max(arrays, function (item) {
return item ? item.length : 0
})
for (len = maxItem ? maxItem.length : 0; index < len; index++) {
result.push(pluck(arrays, index))
}
}
return result
}
module.exports = unzip