26 lines
		
	
	
		
			494 B
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			494 B
		
	
	
	
		
			Java
		
	
	
	
	
	
| var map = require('./map')
 | |
| 
 | |
| var max = require('../number/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(map(arrays, index))
 | |
|     }
 | |
|   }
 | |
|   return result
 | |
| }
 | |
| 
 | |
| module.exports = unzip
 | 
