mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 23:37:49 +00:00
Cleanup _.zipObject.
This commit is contained in:
12
lodash.js
12
lodash.js
@@ -4483,25 +4483,25 @@
|
||||
* @alias object
|
||||
* @category Array
|
||||
* @param {Array} props The property names.
|
||||
* @param {Array} [vals=[]] The property values.
|
||||
* @param {Array} [values=[]] The property values.
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
* _.zipObject(['fred', 'barney'], [30, 40]);
|
||||
* // => { 'fred': 30, 'barney': 40 }
|
||||
*/
|
||||
function zipObject(props, vals) {
|
||||
function zipObject(props, values) {
|
||||
var index = -1,
|
||||
length = props ? props.length : 0,
|
||||
result = {};
|
||||
|
||||
if (!vals && length && !isArray(props[0])) {
|
||||
vals = [];
|
||||
if (!values && length && !isArray(props[0])) {
|
||||
values = [];
|
||||
}
|
||||
while (++index < length) {
|
||||
var key = props[index];
|
||||
if (vals) {
|
||||
result[key] = vals[index];
|
||||
if (values) {
|
||||
result[key] = values[index];
|
||||
} else if (key) {
|
||||
result[key[0]] = key[1];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user