Tweak argument names and docs.

Former-commit-id: 38d7f9cc7dea76e038ede22b6c6b4e779e28237b
This commit is contained in:
John-David Dalton
2013-04-02 22:37:40 -07:00
parent e76360c1b5
commit ca28aa6ebd
7 changed files with 219 additions and 121 deletions

62
dist/lodash.compat.js vendored
View File

@@ -223,8 +223,8 @@
* `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
* `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `push`, `range`,
* `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`,
* `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`,
* `where`, `without`, `wrap`, and `zip`
* `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `unzip`,
* `values`, `where`, `without`, `wrap`, and `zip`
*
* The non-chainable wrapper functions are:
* `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`,
@@ -1254,7 +1254,7 @@
* @static
* @memberOf _
* @category Objects
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Object} object The object to search.
* @param {Function|Object|String} [callback=identity] The function called per
* iteration. If a property name or object is passed, it will be used to create
* a "_.pluck" or "_.where" style callback, respectively.
@@ -1265,11 +1265,11 @@
* _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { return num % 2 == 0; });
* // => 'b'
*/
function findKey(collection, callback, thisArg) {
function findKey(object, callback, thisArg) {
var result;
callback = lodash.createCallback(callback, thisArg);
forOwn(collection, function(value, key, collection) {
if (callback(value, key, collection)) {
forOwn(object, function(value, key, object) {
if (callback(value, key, object)) {
result = key;
return false;
}
@@ -3297,7 +3297,7 @@
* @static
* @memberOf _
* @category Arrays
* @param {Array|Object|String} collection The collection to iterate over.
* @param {Array} array The array to search.
* @param {Function|Object|String} [callback=identity] The function called per
* iteration. If a property name or object is passed, it will be used to create
* a "_.pluck" or "_.where" style callback, respectively.
@@ -3305,16 +3305,18 @@
* @returns {Mixed} Returns the index of the found element, else `-1`.
* @example
*
* _.findIndex(['apple', 'banana', 'beet'], function(food) { return /^b/.test(food); });
* _.findIndex(['apple', 'banana', 'beet'], function(food) {
* return /^b/.test(food);
* });
* // => 1
*/
function findIndex(collection, callback, thisArg) {
function findIndex(array, callback, thisArg) {
var index = -1,
length = collection ? collection.length : 0;
length = array ? array.length : 0;
callback = lodash.createCallback(callback, thisArg);
while (++index < length) {
if (callback(collection[index], index, collection)) {
if (callback(array[index], index, array)) {
return index;
}
}
@@ -3416,7 +3418,7 @@
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to compact.
* @param {Array} array The array to flatten.
* @param {Boolean} [isShallow=false] A flag to indicate only flattening a single level.
* @param {Function|Object|String} [callback=identity] The function called per
* iteration. If a property name or object is passed, it will be used to create
@@ -3887,7 +3889,7 @@
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to iterate over.
* @param {Array} array The array to inspect.
* @param {Mixed} value The value to evaluate.
* @param {Function|Object|String} [callback=identity] The function called per
* iteration. If a property name or object is passed, it will be used to create
@@ -4041,6 +4043,37 @@
return result;
}
/**
* The inverse of `_.zip`, this method splits groups of elements into arrays
* composed of elements from each group at their corresponding indexes.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to process.
* @returns {Array} Returns a new array of the composed arrays.
* @example
*
* _.unzip([['moe', 30, true], ['larry', 40, false]]);
* // => [['moe', 'larry'], [30, 40], [true, false]];
*/
function unzip(array) {
var index = -1,
length = array ? array.length : 0,
tupleLength = length ? max(pluck(array, 'length')) : 0,
result = Array(tupleLength);
while (++index < length) {
var tupleIndex = -1,
tuple = array[index];
while (++tupleIndex < tupleLength) {
(result[tupleIndex] || (result[tupleIndex] = Array(length)))[index] = tuple[tupleIndex];
}
}
return result;
}
/**
* Creates an array with all occurrences of the passed values removed using
* strict equality for comparisons, i.e. `===`.
@@ -5079,7 +5112,7 @@
}
/**
* The opposite of `_.escape`, this method converts the HTML entities
* The inverse of `_.escape`, this method converts the HTML entities
* `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to their
* corresponding characters.
*
@@ -5232,6 +5265,7 @@
lodash.toArray = toArray;
lodash.union = union;
lodash.uniq = uniq;
lodash.unzip = unzip;
lodash.values = values;
lodash.where = where;
lodash.without = without;