Tweak docs and var names of at, baseAt, and zipObject.

This commit is contained in:
John-David Dalton
2014-07-09 00:41:02 -07:00
parent 225c8871f9
commit 1b9dbd0e62

View File

@@ -296,12 +296,13 @@
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/** /**
* The base implementation of `_.at` without support for strings and * The base implementation of `_.at` without support for strings and individual
* individual key arguments. * key arguments.
* *
* @private * @private
* @param {Array|Object} collection The collection to iterate over. * @param {Array|Object} collection The collection to iterate over.
* @param {number[]|string[]} [props] The keys of elements to pick. * @param {number[]|string[]} [props] The property names or indexes of elements
* to pick.
* @returns {Array} Returns the new array of picked elements. * @returns {Array} Returns the new array of picked elements.
*/ */
function baseAt(collection, props) { function baseAt(collection, props) {
@@ -4179,34 +4180,34 @@
} }
/** /**
* Creates an object composed from arrays of `keys` and `values`. Provide * Creates an object composed from arrays of property names and values. Provide
* either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]` * either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`
* or two arrays, one of `keys` and one of corresponding `values`. * or two arrays, one of property names and one of corresponding values.
* *
* @static * @static
* @memberOf _ * @memberOf _
* @alias object * @alias object
* @category Array * @category Array
* @param {Array} keys The array of keys. * @param {Array} props The array of property names.
* @param {Array} [values=[]] The array of values. * @param {Array} [vals=[]] The array of property values.
* @returns {Object} Returns the new object. * @returns {Object} Returns the new object.
* @example * @example
* *
* _.zipObject(['fred', 'barney'], [30, 40]); * _.zipObject(['fred', 'barney'], [30, 40]);
* // => { 'fred': 30, 'barney': 40 } * // => { 'fred': 30, 'barney': 40 }
*/ */
function zipObject(keys, values) { function zipObject(props, vals) {
var index = -1, var index = -1,
length = keys ? keys.length : 0, length = props ? props.length : 0,
result = {}; result = {};
if (!values && length && !isArray(keys[0])) { if (!vals && length && !isArray(props[0])) {
values = []; vals = [];
} }
while (++index < length) { while (++index < length) {
var key = keys[index]; var key = props[index];
if (values) { if (vals) {
result[key] = values[index]; result[key] = vals[index];
} else if (key) { } else if (key) {
result[key[0]] = key[1]; result[key[0]] = key[1];
} }
@@ -4346,8 +4347,8 @@
* @memberOf _ * @memberOf _
* @category Collection * @category Collection
* @param {Array|Object|string} collection The collection to iterate over. * @param {Array|Object|string} collection The collection to iterate over.
* @param {...(number|number[]|string|string[])} [keys] The keys of elements * @param {...(number|number[]|string|string[])} [props] The property names
* to pick, specified as individual keys or arrays of keys. * or indexes of elements to pick, specified individually or in arrays.
* @returns {Array} Returns the new array of picked elements. * @returns {Array} Returns the new array of picked elements.
* @example * @example
* *