Permalink
Cannot retrieve contributors at this time
45 lines (42 sloc)
1.25 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/lodash/unzip.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arrayFilter = require('./_arrayFilter'), | |
arrayMap = require('./_arrayMap'), | |
baseProperty = require('./_baseProperty'), | |
baseTimes = require('./_baseTimes'), | |
isArrayLikeObject = require('./isArrayLikeObject'); | |
/* Built-in 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 | |
* configuration. | |
* | |
* @static | |
* @memberOf _ | |
* @since 1.2.0 | |
* @category Array | |
* @param {Array} array The array of grouped elements to process. | |
* @returns {Array} Returns the new array of regrouped elements. | |
* @example | |
* | |
* var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); | |
* // => [['a', 1, true], ['b', 2, false]] | |
* | |
* _.unzip(zipped); | |
* // => [['a', 'b'], [1, 2], [true, false]] | |
*/ | |
function unzip(array) { | |
if (!(array && array.length)) { | |
return []; | |
} | |
var length = 0; | |
array = arrayFilter(array, function(group) { | |
if (isArrayLikeObject(group)) { | |
length = nativeMax(group.length, length); | |
return true; | |
} | |
}); | |
return baseTimes(length, function(index) { | |
return arrayMap(array, baseProperty(index)); | |
}); | |
} | |
module.exports = unzip; |