mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Bump to v3.8.0.
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import arrayFilter from '../internal/arrayFilter';
|
||||
import arrayMap from '../internal/arrayMap';
|
||||
import arrayMax from '../internal/arrayMax';
|
||||
import baseProperty from '../internal/baseProperty';
|
||||
import getLength from '../internal/getLength';
|
||||
import isArrayLike from '../internal/isArrayLike';
|
||||
|
||||
/* Native method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMax = Math.max;
|
||||
|
||||
/**
|
||||
* This method is like `_.zip` except that it accepts an array of grouped
|
||||
* elements and creates an array regrouping the elements to their pre-`_.zip`
|
||||
* elements and creates an array regrouping the elements to their pre-zip
|
||||
* configuration.
|
||||
*
|
||||
* @static
|
||||
@@ -22,10 +25,19 @@ import getLength from '../internal/getLength';
|
||||
* // => [['fred', 'barney'], [30, 40], [true, false]]
|
||||
*/
|
||||
function unzip(array) {
|
||||
if (!(array && array.length)) {
|
||||
return [];
|
||||
}
|
||||
var index = -1,
|
||||
length = (array && array.length && arrayMax(arrayMap(array, getLength))) >>> 0,
|
||||
result = Array(length);
|
||||
length = 0;
|
||||
|
||||
array = arrayFilter(array, function(group) {
|
||||
if (isArrayLike(group)) {
|
||||
length = nativeMax(group.length, length);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
var result = Array(length);
|
||||
while (++index < length) {
|
||||
result[index] = arrayMap(array, baseProperty(index));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user