mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Rename _.object to _.zipObject and make _.object an alias of _.zipObject.
Former-commit-id: 7ae3c9d8be32b1430945ffeafc20c740f1d7f409
This commit is contained in:
77
dist/lodash.underscore.js
vendored
77
dist/lodash.underscore.js
vendored
@@ -395,12 +395,12 @@
|
||||
};
|
||||
}
|
||||
if (argCount === 4) {
|
||||
return function(accumulator, value, index, object) {
|
||||
return func.call(thisArg, accumulator, value, index, object);
|
||||
return function(accumulator, value, index, collection) {
|
||||
return func.call(thisArg, accumulator, value, index, collection);
|
||||
};
|
||||
}
|
||||
return function(value, index, object) {
|
||||
return func.call(thisArg, value, index, object);
|
||||
return function(value, index, collection) {
|
||||
return func.call(thisArg, value, index, collection);
|
||||
};
|
||||
}
|
||||
return func;
|
||||
@@ -2895,39 +2895,6 @@
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object composed from arrays of `keys` and `values`. Pass either
|
||||
* a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or
|
||||
* two arrays, one of `keys` and one of corresponding `values`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Arrays
|
||||
* @param {Array} keys The array of keys.
|
||||
* @param {Array} [values=[]] The array of values.
|
||||
* @returns {Object} Returns an object composed of the given keys and
|
||||
* corresponding values.
|
||||
* @example
|
||||
*
|
||||
* _.object(['moe', 'larry'], [30, 40]);
|
||||
* // => { 'moe': 30, 'larry': 40 }
|
||||
*/
|
||||
function object(keys, values) {
|
||||
var index = -1,
|
||||
length = keys ? keys.length : 0,
|
||||
result = {};
|
||||
|
||||
while (++index < length) {
|
||||
var key = keys[index];
|
||||
if (values) {
|
||||
result[key] = values[index];
|
||||
} else {
|
||||
result[key[0]] = key[1];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of numbers (positive and/or negative) progressing from
|
||||
* `start` up to but not including `end`.
|
||||
@@ -3266,6 +3233,40 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object composed from arrays of `keys` and `values`. Pass either
|
||||
* a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or
|
||||
* two arrays, one of `keys` and one of corresponding `values`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @alias object
|
||||
* @category Arrays
|
||||
* @param {Array} keys The array of keys.
|
||||
* @param {Array} [values=[]] The array of values.
|
||||
* @returns {Object} Returns an object composed of the given keys and
|
||||
* corresponding values.
|
||||
* @example
|
||||
*
|
||||
* _.zipObject(['moe', 'larry'], [30, 40]);
|
||||
* // => { 'moe': 30, 'larry': 40 }
|
||||
*/
|
||||
function zipObject(keys, values) {
|
||||
var index = -1,
|
||||
length = keys ? keys.length : 0,
|
||||
result = {};
|
||||
|
||||
while (++index < length) {
|
||||
var key = keys[index];
|
||||
if (values) {
|
||||
result[key] = values[index];
|
||||
} else {
|
||||
result[key[0]] = key[1];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@@ -4153,7 +4154,6 @@
|
||||
lodash.max = max;
|
||||
lodash.memoize = memoize;
|
||||
lodash.min = min;
|
||||
lodash.object = object;
|
||||
lodash.omit = omit;
|
||||
lodash.once = once;
|
||||
lodash.pairs = pairs;
|
||||
@@ -4183,6 +4183,7 @@
|
||||
lodash.each = forEach;
|
||||
lodash.extend = assign;
|
||||
lodash.methods = functions;
|
||||
lodash.object = zipObject;
|
||||
lodash.select = filter;
|
||||
lodash.tail = rest;
|
||||
lodash.unique = uniq;
|
||||
|
||||
Reference in New Issue
Block a user