This commit is contained in:
毛财君
2023-07-06 17:37:33 +08:00
parent 06f26608af
commit 197b38ca6f
816 changed files with 236883 additions and 989 deletions

View File

@@ -0,0 +1,25 @@
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