From 2aa94301a859ff4097c8cc40918c61abbc67de2c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 1 Aug 2014 11:13:58 -0700 Subject: [PATCH] Rename `iterator` to `iteratee`. --- lodash.js | 474 +++++++++++++++++++++++++++--------------------------- 1 file changed, 237 insertions(+), 237 deletions(-) diff --git a/lodash.js b/lodash.js index d793e045e..53987c991 100644 --- a/lodash.js +++ b/lodash.js @@ -1076,15 +1076,15 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns `array`. */ - function arrayEach(array, iterator) { + function arrayEach(array, iteratee) { var index = -1, length = array.length; while (++index < length) { - if (iterator(array[index], index, array) === false) { + if (iteratee(array[index], index, array) === false) { break; } } @@ -1097,14 +1097,14 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns `array`. */ - function arrayEachRight(array, iterator) { + function arrayEachRight(array, iteratee) { var length = array.length; while (length--) { - if (iterator(array[length], length, array) === false) { + if (iteratee(array[length], length, array) === false) { break; } } @@ -1139,16 +1139,16 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns the new mapped array. */ - function arrayMap(array, iterator) { + function arrayMap(array, iteratee) { var index = -1, length = array.length, result = Array(length); while (++index < length) { - result[index] = iterator(array[index], index, array); + result[index] = iteratee(array[index], index, array); } return result; } @@ -1183,13 +1183,13 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {*} [accumulator] The initial value. * @param {boolean} [initFromArray=false] Specify using the first element of * `array` as the initial value. * @returns {*} Returns the accumulated value. */ - function arrayReduce(array, iterator, accumulator, initFromArray) { + function arrayReduce(array, iteratee, accumulator, initFromArray) { var index = -1, length = array.length; @@ -1197,7 +1197,7 @@ accumulator = array[++index]; } while (++index < length) { - accumulator = iterator(accumulator, array[index], index, array); + accumulator = iteratee(accumulator, array[index], index, array); } return accumulator; } @@ -1208,20 +1208,20 @@ * * @private * @param {Array} array The array to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {*} [accumulator] The initial value. * @param {boolean} [initFromArray=false] Specify using the last element of * `array` as the initial value. * @returns {*} Returns the accumulated value. */ - function arrayReduceRight(array, iterator, accumulator, initFromArray) { + function arrayReduceRight(array, iteratee, accumulator, initFromArray) { var length = array.length; if (initFromArray && length) { accumulator = array[--length]; } while (length--) { - accumulator = iterator(accumulator, array[length], length, array); + accumulator = iteratee(accumulator, array[length], length, array); } return accumulator; } @@ -1681,19 +1681,19 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array|Object|string} Returns `collection`. */ - function baseEach(collection, iterator) { + function baseEach(collection, iteratee) { var length = collection ? collection.length : 0; if (!(typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER)) { - return baseForOwn(collection, iterator); + return baseForOwn(collection, iteratee); } var index = -1, iterable = toIterable(collection); while (++index < length) { - if (iterator(iterable[index], index, iterable) === false) { + if (iteratee(iterable[index], index, iterable) === false) { break; } } @@ -1706,17 +1706,17 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array|Object|string} Returns `collection`. */ - function baseEachRight(collection, iterator) { + function baseEachRight(collection, iteratee) { var length = collection ? collection.length : 0; if (!(typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER)) { - return baseForOwnRight(collection, iterator); + return baseForOwnRight(collection, iteratee); } var iterable = toIterable(collection); while (length--) { - if (iterator(iterable[length], length, iterable) === false) { + if (iteratee(iterable[length], length, iterable) === false) { break; } } @@ -1830,24 +1830,24 @@ /** * The base implementation of `baseForIn` and `baseForOwn` which iterates - * over `object` properties returned by `keysFunc` executing `iterator` for + * over `object` properties returned by `keysFunc` executing `iteratee` for * each property. Iterator functions may exit iteration early by explicitly * returning `false`. * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ - function baseFor(object, iterator, keysFunc) { + function baseFor(object, iteratee, keysFunc) { var index = -1, props = keysFunc(object), length = props.length; while (++index < length) { var key = props[index]; - if (iterator(object[key], key, object) === false) { + if (iteratee(object[key], key, object) === false) { break; } } @@ -1860,17 +1860,17 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {Function} keysFunc The function to get the keys of `object`. * @returns {Object} Returns `object`. */ - function baseForRight(object, iterator, keysFunc) { + function baseForRight(object, iteratee, keysFunc) { var props = keysFunc(object), length = props.length; while (length--) { var key = props[length]; - if (iterator(object[key], key, object) === false) { + if (iteratee(object[key], key, object) === false) { break; } } @@ -1883,11 +1883,11 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Object} Returns `object`. */ - function baseForIn(object, iterator) { - return baseFor(object, iterator, keysIn); + function baseForIn(object, iteratee) { + return baseFor(object, iteratee, keysIn); } /** @@ -1896,11 +1896,11 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Object} Returns `object`. */ - function baseForOwn(object, iterator) { - return baseFor(object, iterator, keys); + function baseForOwn(object, iteratee) { + return baseFor(object, iteratee, keys); } /** @@ -1909,11 +1909,11 @@ * * @private * @param {Object} object The object to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Object} Returns `object`. */ - function baseForOwnRight(object, iterator) { - return baseForRight(object, iterator, keys); + function baseForOwnRight(object, iteratee) { + return baseForRight(object, iteratee, keys); } /** @@ -2166,14 +2166,14 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @returns {Array} Returns the new mapped array. */ - function baseMap(collection, iterator) { + function baseMap(collection, iteratee) { var result = []; baseEach(collection, function(value, key, collection) { - result.push(iterator(value, key, collection)); + result.push(iteratee(value, key, collection)); }); return result; } @@ -2347,18 +2347,18 @@ * * @private * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {*} accumulator The initial value. * @param {boolean} initFromCollection Specify using the first or last element * of `collection` as the initial value. * @param {Function} eachFunc The function to iterate over `collection`. * @returns {*} Returns the accumulated value. */ - function baseReduce(collection, iterator, accumulator, initFromCollection, eachFunc) { + function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) { eachFunc(collection, function(value, index, collection) { accumulator = initFromCollection ? (initFromCollection = false, value) - : iterator(accumulator, value, index, collection) + : iteratee(accumulator, value, index, collection) }); return accumulator; } @@ -2390,23 +2390,23 @@ * @private * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. - * @param {Function} iterator The function called per iteration. + * @param {Function} iteratee The function called per iteration. * @param {boolean} [retHighest=false] Specify returning the highest, instead * of the lowest, index at which a value should be inserted into `array`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. */ - function baseSortedIndex(array, value, iterator, retHighest) { + function baseSortedIndex(array, value, iteratee, retHighest) { var low = 0, high = array ? array.length : low; - value = iterator(value); + value = iteratee(value); var hintNum = typeof value == 'number' || (value != null && isFunction(value.valueOf) && typeof value.valueOf() == 'number'); while (low < high) { var mid = (low + high) >>> 1, - computed = iterator(array[mid]), + computed = iteratee(array[mid]), setLow = retHighest ? (computed <= value) : (computed < value); if (hintNum && typeof computed != 'undefined') { @@ -2428,10 +2428,10 @@ * * @private * @param {Array} array The array to inspect. - * @param {Function} [iterator] The function called per iteration. + * @param {Function} [iteratee] The function called per iteration. * @returns {Array} Returns the new duplicate-value-free array. */ - function baseUniq(array, iterator) { + function baseUniq(array, iteratee) { var index = -1, indexOf = getIndexOf(), length = array.length, @@ -2444,12 +2444,12 @@ var seen = createCache(); indexOf = cacheIndexOf; } else { - seen = iterator ? [] : result; + seen = iteratee ? [] : result; } outer: while (++index < length) { var value = array[index], - computed = iterator ? iterator(value, index, array) : value; + computed = iteratee ? iteratee(value, index, array) : value; if (isCommon && value === value) { var seenIndex = seen.length; @@ -2458,13 +2458,13 @@ continue outer; } } - if (iterator) { + if (iteratee) { seen.push(computed); } result.push(value); } else if (indexOf(seen, computed) < 0) { - if (iterator || isLarge) { + if (iteratee || isLarge) { seen.push(computed); } result.push(value); @@ -2560,7 +2560,7 @@ /** * Creates a function that aggregates a collection, creating an accumulator * object composed from the results of running each element in the collection - * through `iterator`. The given setter function sets the keys and values of + * through `iteratee`. The given setter function sets the keys and values of * the accumulator object. If `initializer` is provided it is used to initialize * the accumulator object. * @@ -2570,9 +2570,9 @@ * @returns {Function} Returns the new aggregator function. */ function createAggregator(setter, initializer) { - return function(collection, iterator, thisArg) { + return function(collection, iteratee, thisArg) { var result = initializer ? initializer() : {}; - iterator = getCallback(iterator, thisArg, 3); + iteratee = getCallback(iteratee, thisArg, 3); if (isArray(collection)) { var index = -1, @@ -2580,11 +2580,11 @@ while (++index < length) { var value = collection[index]; - setter(result, value, iterator(value, index, collection), collection); + setter(result, value, iteratee(value, index, collection), collection); } } else { baseEach(collection, function(value, key, collection) { - setter(result, value, iterator(value, key, collection), collection); + setter(result, value, iteratee(value, key, collection), collection); }); } return result; @@ -3064,10 +3064,10 @@ * * @private * @param {Array} array The array to inspect. - * @param {Function} [iterator] The function called per iteration. + * @param {Function} [iteratee] The function called per iteration. * @returns {Array} Returns the new duplicate-value-free array. */ - function sortedUniq(array, iterator) { + function sortedUniq(array, iteratee) { var seen, index = -1, length = array.length, @@ -3076,7 +3076,7 @@ while (++index < length) { var value = array[index], - computed = iterator ? iterator(value, index, array) : value; + computed = iteratee ? iteratee(value, index, array) : value; if (!index || seen !== computed) { seen = computed; @@ -3916,14 +3916,14 @@ /** * Uses a binary search to determine the lowest index at which a value should * be inserted into a given sorted array in order to maintain the sort order - * of the array. If an iterator function is provided it is executed for `value` - * and each element of `array` to compute their sort ranking. The iterator + * of the array. If an iteratee function is provided it is executed for `value` + * and each element of `array` to compute their sort ranking. The iteratee * function is bound to `thisArg` and invoked with one argument; (value). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * If an object is provided for `iteratee` the created "_.where" style callback * returns `true` for elements that have the properties of the given object, * else `false`. * @@ -3932,10 +3932,10 @@ * @category Array * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. * @example @@ -3948,7 +3948,7 @@ * * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } }; * - * // using an iterator function + * // using an iteratee function * _.sortedIndex(['thirty', 'fifty'], 'forty', function(word) { * return this.data[word]; * }, dict); @@ -3958,9 +3958,9 @@ * _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); * // => 1 */ - function sortedIndex(array, value, iterator, thisArg) { - iterator = iterator == null ? identity : getCallback(iterator, thisArg, 1); - return baseSortedIndex(array, value, iterator); + function sortedIndex(array, value, iteratee, thisArg) { + iteratee = iteratee == null ? identity : getCallback(iteratee, thisArg, 1); + return baseSortedIndex(array, value, iteratee); } /** @@ -3973,10 +3973,10 @@ * @category Array * @param {Array} array The array to inspect. * @param {*} value The value to evaluate. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {number} Returns the index at which `value` should be inserted * into `array`. * @example @@ -3984,9 +3984,9 @@ * _.sortedLastIndex([4, 4, 5, 5, 6, 6], 5); * // => 4 */ - function sortedLastIndex(array, value, iterator, thisArg) { - iterator = iterator == null ? identity : getCallback(iterator, thisArg, 1); - return baseSortedIndex(array, value, iterator, true); + function sortedLastIndex(array, value, iteratee, thisArg) { + iteratee = iteratee == null ? identity : getCallback(iteratee, thisArg, 1); + return baseSortedIndex(array, value, iteratee, true); } /** @@ -4174,15 +4174,15 @@ /** * Creates a duplicate-value-free version of an array using `SameValueZero` * for equality comparisons. Providing `true` for `isSorted` performs a faster - * search algorithm for sorted arrays. If an iterator function is provided it + * search algorithm for sorted arrays. If an iteratee function is provided it * is executed for each value in the array to generate the criterion by which - * uniqueness is computed. The `iterator` is bound to `thisArg` and invoked + * uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked * with three arguments; (value, index, array). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * If an object is provided for `iteratee` the created "_.where" style callback * returns `true` for elements that have the properties of the given object, * else `false`. * @@ -4196,10 +4196,10 @@ * @category Array * @param {Array} array The array to inspect. * @param {boolean} [isSorted=false] Specify the array is sorted. - * @param {Function|Object|string} [iterator] The function called per iteration. + * @param {Function|Object|string} [iteratee] The function called per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new duplicate-value-free array. * @example * @@ -4210,7 +4210,7 @@ * _.uniq([1, 1, 2], true); * // => [1, 2] * - * // using an iterator function + * // using an iteratee function * _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); * // => [1, 2.5] * @@ -4218,7 +4218,7 @@ * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }, { 'x': 2 }] */ - function uniq(array, isSorted, iterator, thisArg) { + function uniq(array, isSorted, iteratee, thisArg) { var length = array ? array.length : 0; if (!length) { return []; @@ -4226,21 +4226,21 @@ // juggle arguments var type = typeof isSorted; if (type != 'boolean' && isSorted != null) { - thisArg = iterator; - iterator = isSorted; + thisArg = iteratee; + iteratee = isSorted; isSorted = false; // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === array) { - iterator = null; + if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === array) { + iteratee = null; } } - if (iterator != null) { - iterator = getCallback(iterator, thisArg, 3); + if (iteratee != null) { + iteratee = getCallback(iteratee, thisArg, 3); } return (isSorted && getIndexOf() == baseIndexOf) - ? sortedUniq(array, iterator) - : baseUniq(array, iterator); + ? sortedUniq(array, iteratee) + : baseUniq(array, iteratee); } /** @@ -4591,15 +4591,15 @@ /** * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iterator`. The corresponding value - * of each key is the number of times the key was returned by `iterator`. - * The `iterator` is bound to `thisArg` and invoked with three arguments; + * each element of `collection` through `iteratee`. The corresponding value + * of each key is the number of times the key was returned by `iteratee`. + * The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * If an object is provided for `iteratee` the created "_.where" style callback * returns `true` for elements that have the properties of the given object, * else `false`. * @@ -4607,10 +4607,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example * @@ -4827,8 +4827,8 @@ } /** - * Iterates over elements of `collection` executing `iterator` for each - * element. The `iterator` is bound to `thisArg` and invoked with three arguments; + * Iterates over elements of `collection` executing `iteratee` for each + * element. The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). Iterator functions may exit iteration early * by explicitly returning `false`. * @@ -4841,8 +4841,8 @@ * @alias each * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array|Object|string} Returns `collection`. * @example * @@ -4852,10 +4852,10 @@ * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); }); * // => logs each value-key pair and returns the object (property order is not guaranteed across environments) */ - function forEach(collection, iterator, thisArg) { - return (typeof iterator == 'function' && typeof thisArg == 'undefined' && isArray(collection)) - ? arrayEach(collection, iterator) - : baseEach(collection, baseCallback(iterator, thisArg, 3)); + function forEach(collection, iteratee, thisArg) { + return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) + ? arrayEach(collection, iteratee) + : baseEach(collection, baseCallback(iteratee, thisArg, 3)); } /** @@ -4867,31 +4867,31 @@ * @alias eachRight * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array|Object|string} Returns `collection`. * @example * * _([1, 2, 3]).forEachRight(function(n) { console.log(n); }).join(','); * // => logs each value from right to left and returns the array */ - function forEachRight(collection, iterator, thisArg) { - return (typeof iterator == 'function' && typeof thisArg == 'undefined' && isArray(collection)) - ? arrayEachRight(collection, iterator) - : baseEachRight(collection, baseCallback(iterator, thisArg, 3)); + function forEachRight(collection, iteratee, thisArg) { + return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection)) + ? arrayEachRight(collection, iteratee) + : baseEachRight(collection, baseCallback(iteratee, thisArg, 3)); } /** * Creates an object composed of keys generated from the results of running - * each element of `collection` through `iterator`. The corresponding + * each element of `collection` through `iteratee`. The corresponding * value of each key is an array of the elements responsible for generating - * the key. The `iterator` is bound to `thisArg` and invoked with three + * the key. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * If an object is provided for `iteratee` the created "_.where" style callback * returns `true` for elements that have the properties of the given object, * else `false`. * @@ -4899,10 +4899,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example * @@ -4926,15 +4926,15 @@ /** * Creates an object composed of keys generated from the results of running - * each element of the collection through `iterator`. The corresponding value + * each element of the collection through `iteratee`. The corresponding value * of each key is the last element responsible for generating the key. The - * iterator function is bound to `thisArg` and invoked with three arguments; + * iteratee function is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * If an object is provided for `iteratee` the created "_.where" style callback * returns `true` for elements that have the properties of the given object, * else `false`. * @@ -4942,10 +4942,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the composed aggregate object. * @example * @@ -4995,13 +4995,13 @@ /** * Creates an array of values by running each element in the collection through - * `iterator`. The `iterator` is bound to `thisArg` and invoked with three + * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three * arguments; (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * If an object is provided for `iteratee` the created "_.where" style callback * returns `true` for elements that have the properties of the given object, * else `false`. * @@ -5010,10 +5010,10 @@ * @alias collect * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new mapped array. * @example * @@ -5032,24 +5032,24 @@ * _.map(characters, 'name'); * // => ['barney', 'fred'] */ - function map(collection, iterator, thisArg) { - iterator = getCallback(iterator, thisArg, 3); + function map(collection, iteratee, thisArg) { + iteratee = getCallback(iteratee, thisArg, 3); var func = isArray(collection) ? arrayMap : baseMap; - return func(collection, iterator); + return func(collection, iteratee); } /** * Retrieves the maximum value of `collection`. If the collection is empty - * or falsey `-Infinity` is returned. If an iterator function is provided it + * or falsey `-Infinity` is returned. If an iteratee function is provided it * is executed for each value in the collection to generate the criterion by - * which the value is ranked. The `iterator` is bound to `thisArg` and invoked + * which the value is ranked. The `iteratee` is bound to `thisArg` and invoked * with three arguments; (value, index, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * If an object is provided for `iteratee` the created "_.where" style callback * returns `true` for elements that have the properties of the given object, * else `false`. * @@ -5057,10 +5057,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator] The function called per iteration. + * @param {Function|Object|string} [iteratee] The function called per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the maximum value. * @example * @@ -5082,16 +5082,16 @@ * _.max(characters, 'age'); * // => { 'name': 'fred', 'age': 40 }; */ - function max(collection, iterator, thisArg) { + function max(collection, iteratee, thisArg) { var computed = -Infinity, result = computed, - type = typeof iterator; + type = typeof iteratee; // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === collection) { - iterator = null; + if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { + iteratee = null; } - var noIterator = iterator == null, + var noIterator = iteratee == null, isArr = noIterator && isArray(collection), isStr = !isArr && isString(collection); @@ -5107,12 +5107,12 @@ } } } else { - iterator = (noIterator && isStr) + iteratee = (noIterator && isStr) ? charAtCallback - : getCallback(iterator, thisArg, 3); + : getCallback(iteratee, thisArg, 3); baseEach(collection, function(value, index, collection) { - var current = iterator(value, index, collection); + var current = iteratee(value, index, collection); if (current > computed || (current === -Infinity && current === result)) { computed = current; result = value; @@ -5124,15 +5124,15 @@ /** * Retrieves the minimum value of `collection`. If the collection is empty - * or falsey `Infinity` is returned. If an iterator function is provided it + * or falsey `Infinity` is returned. If an iteratee function is provided it * is executed for each value in the collection to generate the criterion by - * which the value is ranked. The `iterator` is bound to `thisArg` and invoked + * which the value is ranked. The `iteratee` is bound to `thisArg` and invoked * with three arguments; (value, index, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * If an object is provided for `iteratee` the created "_.where" style callback * returns `true` for elements that have the properties of the given object, * else `false`. * @@ -5140,10 +5140,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iterator] The function called per iteration. + * @param {Function|Object|string} [iteratee] The function called per iteration. * If a property name or object is provided it is used to create a "_.pluck" * or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the minimum value. * @example * @@ -5165,16 +5165,16 @@ * _.min(characters, 'age'); * // => { 'name': 'barney', 'age': 36 }; */ - function min(collection, iterator, thisArg) { + function min(collection, iteratee, thisArg) { var computed = Infinity, result = computed, - type = typeof iterator; + type = typeof iteratee; // enables use as a callback for functions like `_.map` - if ((type == 'number' || type == 'string') && thisArg && thisArg[iterator] === collection) { - iterator = null; + if ((type == 'number' || type == 'string') && thisArg && thisArg[iteratee] === collection) { + iteratee = null; } - var noIterator = iterator == null, + var noIterator = iteratee == null, isArr = noIterator && isArray(collection), isStr = !isArr && isString(collection); @@ -5190,12 +5190,12 @@ } } } else { - iterator = (noIterator && isStr) + iteratee = (noIterator && isStr) ? charAtCallback - : getCallback(iterator, thisArg, 3); + : getCallback(iteratee, thisArg, 3); baseEach(collection, function(value, index, collection) { - var current = iterator(value, index, collection); + var current = iteratee(value, index, collection); if (current < computed || (current === Infinity && current === result)) { computed = current; result = value; @@ -5278,10 +5278,10 @@ /** * Reduces a collection to a value which is the accumulated result of running - * each element in the collection through `iterator`, where each successive + * each element in the collection through `iteratee`, where each successive * execution consumes the return value of the previous execution. If `accumulator` * is not provided the first element of the collection is used as the initial - * value. The `iterator` is bound to `thisArg`and invoked with four arguments; + * value. The `iteratee` is bound to `thisArg`and invoked with four arguments; * (accumulator, value, index|key, collection). * * @static @@ -5289,9 +5289,9 @@ * @alias foldl, inject * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. + * @param {Function} [iteratee=identity] The function called per iteration. * @param {*} [accumulator] The initial value. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the accumulated value. * @example * @@ -5304,9 +5304,9 @@ * }, {}); * // => { 'a': 3, 'b': 6, 'c': 9 } */ - function reduce(collection, iterator, accumulator, thisArg) { + function reduce(collection, iteratee, accumulator, thisArg) { var func = isArray(collection) ? arrayReduce : baseReduce; - return func(collection, getCallback(iterator, thisArg, 4), accumulator, arguments.length < 3, baseEach); + return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEach); } /** @@ -5318,9 +5318,9 @@ * @alias foldr * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. + * @param {Function} [iteratee=identity] The function called per iteration. * @param {*} [accumulator] The initial value. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the accumulated value. * @example * @@ -5328,9 +5328,9 @@ * _.reduceRight(array, function(flattened, other) { return flattened.concat(other); }, []); * // => [4, 5, 2, 3, 0, 1] */ - function reduceRight(collection, iterator, accumulator, thisArg) { + function reduceRight(collection, iteratee, accumulator, thisArg) { var func = isArray(collection) ? arrayReduceRight : baseReduce; - return func(collection, getCallback(iterator, thisArg, 4), accumulator, arguments.length < 3, baseEachRight); + return func(collection, getCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEachRight); } /** @@ -5516,18 +5516,18 @@ /** * Creates an array of elements, sorted in ascending order by the results of - * running each element in a collection through `iterator`. This method performs + * running each element in a collection through `iteratee`. This method performs * a stable sort, that is, it preserves the original sort order of equal elements. - * The `iterator` is bound to `thisArg` and invoked with three arguments; + * The `iteratee` is bound to `thisArg` and invoked with three arguments; * (value, index|key, collection). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an array of property names is provided for `iterator` the collection + * If an array of property names is provided for `iteratee` the collection * is sorted by each property value. * - * If an object is provided for `iterator` the created "_.where" style callback + * If an object is provided for `iteratee` the created "_.where" style callback * returns `true` for elements that have the properties of the given object, * else `false`. * @@ -5535,10 +5535,10 @@ * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {Array|Function|Object|string} [iterator=identity] The function + * @param {Array|Function|Object|string} [iteratee=identity] The function * called per iteration. If property name(s) or an object is provided it * is used to create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the new sorted array. * @example * @@ -5563,28 +5563,28 @@ * _.map(_.sortBy(characters, ['name', 'age']), _.values); * // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] */ - function sortBy(collection, iterator, thisArg) { + function sortBy(collection, iteratee, thisArg) { var index = -1, length = collection ? collection.length : 0, - multi = iterator && isArray(iterator), + multi = iteratee && isArray(iteratee), result = []; if (typeof length == 'number' && length > -1 && length <= MAX_SAFE_INTEGER) { result.length = length; } if (!multi) { - iterator = getCallback(iterator, thisArg, 3); + iteratee = getCallback(iteratee, thisArg, 3); } baseEach(collection, function(value, key, collection) { if (multi) { - var length = iterator.length, + var length = iteratee.length, criteria = Array(length); while (length--) { - criteria[length] = value[iterator[length]]; + criteria[length] = value[iteratee[length]]; } } else { - criteria = iterator(value, key, collection); + criteria = iteratee(value, key, collection); } result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; }); @@ -6727,7 +6727,7 @@ /** * Iterates over own and inherited enumerable properties of an object executing - * `iterator` for each property. The `iterator` is bound to `thisArg` and invoked + * `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked * with three arguments; (value, key, object). Iterator functions may exit * iteration early by explicitly returning `false`. * @@ -6735,8 +6735,8 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns `object`. * @example * @@ -6752,11 +6752,11 @@ * }); * // => logs 'x', 'y', and 'z' (property order is not guaranteed across environments) */ - function forIn(object, iterator, thisArg) { - if (typeof iterator != 'function' || typeof thisArg != 'undefined') { - iterator = baseCallback(iterator, thisArg, 3); + function forIn(object, iteratee, thisArg) { + if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { + iteratee = baseCallback(iteratee, thisArg, 3); } - return baseFor(object, iterator, keysIn); + return baseFor(object, iteratee, keysIn); } /** @@ -6767,8 +6767,8 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns `object`. * @example * @@ -6784,14 +6784,14 @@ * }); * // => logs 'z', 'y', and 'x' assuming `_.forIn ` logs 'x', 'y', and 'z' */ - function forInRight(object, iterator, thisArg) { - iterator = baseCallback(iterator, thisArg, 3); - return baseForRight(object, iterator, keysIn); + function forInRight(object, iteratee, thisArg) { + iteratee = baseCallback(iteratee, thisArg, 3); + return baseForRight(object, iteratee, keysIn); } /** - * Iterates over own enumerable properties of an object executing `iterator` - * for each property. The `iterator` is bound to `thisArg` and invoked with + * Iterates over own enumerable properties of an object executing `iteratee` + * for each property. The `iteratee` is bound to `thisArg` and invoked with * three arguments; (value, key, object). Iterator functions may exit iteration * early by explicitly returning `false`. * @@ -6799,8 +6799,8 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns `object`. * @example * @@ -6809,11 +6809,11 @@ * }); * // => logs '0', '1', and 'length' (property order is not guaranteed across environments) */ - function forOwn(object, iterator, thisArg) { - if (typeof iterator != 'function' || typeof thisArg != 'undefined') { - iterator = baseCallback(iterator, thisArg, 3); + function forOwn(object, iteratee, thisArg) { + if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { + iteratee = baseCallback(iteratee, thisArg, 3); } - return baseForOwn(object, iterator); + return baseForOwn(object, iteratee); } /** @@ -6824,8 +6824,8 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns `object`. * @example * @@ -6834,9 +6834,9 @@ * }); * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' */ - function forOwnRight(object, iterator, thisArg) { - iterator = baseCallback(iterator, thisArg, 3); - return baseForRight(object, iterator, keys); + function forOwnRight(object, iteratee, thisArg) { + iteratee = baseCallback(iteratee, thisArg, 3); + return baseForRight(object, iteratee, keys); } /** @@ -7536,14 +7536,14 @@ /** * Creates an object with the same keys as `object` and values generated by - * running each own enumerable property of `object` through `iterator`. The - * iterator function is bound to `thisArg` and invoked with three arguments; + * running each own enumerable property of `object` through `iteratee`. The + * iteratee function is bound to `thisArg` and invoked with three arguments; * (value, key, object). * - * If a property name is provided for `iterator` the created "_.pluck" style + * If a property name is provided for `iteratee` the created "_.pluck" style * callback returns the property value of the given element. * - * If an object is provided for `iterator` the created "_.where" style callback + * If an object is provided for `iteratee` the created "_.where" style callback * returns `true` for elements that have the properties of the given object, * else `false`. * @@ -7551,10 +7551,10 @@ * @memberOf _ * @category Object * @param {Object} object The object to iterate over. - * @param {Function|Object|string} [iterator=identity] The function called + * @param {Function|Object|string} [iteratee=identity] The function called * per iteration. If a property name or object is provided it is used to * create a "_.pluck" or "_.where" style callback respectively. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Object} Returns the new mapped object. * @example * @@ -7570,12 +7570,12 @@ * _.mapValues(characters, 'age'); * // => { 'fred': 40, 'pebbles': 1 } */ - function mapValues(object, iterator, thisArg) { + function mapValues(object, iteratee, thisArg) { var result = {}; - iterator = getCallback(iterator, thisArg, 3); + iteratee = getCallback(iteratee, thisArg, 3); baseForOwn(object, function(value, key, object) { - result[key] = iterator(value, key, object); + result[key] = iteratee(value, key, object); }); return result; } @@ -7739,8 +7739,8 @@ /** * An alternative to `_.reduce`; this method transforms `object` to a new * `accumulator` object which is the result of running each of its own - * enumerable properties through `iterator`, with each execution potentially - * mutating the `accumulator` object. The `iterator` is bound to `thisArg` + * enumerable properties through `iteratee`, with each execution potentially + * mutating the `accumulator` object. The `iteratee` is bound to `thisArg` * and invoked with four arguments; (accumulator, value, key, object). Iterator * functions may exit iteration early by explicitly returning `false`. * @@ -7748,9 +7748,9 @@ * @memberOf _ * @category Object * @param {Array|Object} object The object to iterate over. - * @param {Function} [iterator=identity] The function called per iteration. + * @param {Function} [iteratee=identity] The function called per iteration. * @param {*} [accumulator] The custom accumulator value. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {*} Returns the accumulated value. * @example * @@ -7767,7 +7767,7 @@ * }); * // => { 'a': 3, 'b': 6, 'c': 9 } */ - function transform(object, iterator, accumulator, thisArg) { + function transform(object, iteratee, accumulator, thisArg) { var isArr = isArrayLike(object); if (accumulator == null) { @@ -7781,10 +7781,10 @@ accumulator = baseCreate(proto); } } - if (iterator) { - iterator = getCallback(iterator, thisArg, 4); + if (iteratee) { + iteratee = getCallback(iteratee, thisArg, 4); (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { - return iterator(accumulator, value, index, object); + return iteratee(accumulator, value, index, object); }); } return accumulator; @@ -9113,16 +9113,16 @@ } /** - * Executes the iterator function `n` times, returning an array of the results - * of each execution. The `iterator` is bound to `thisArg` and invoked with + * Executes the iteratee function `n` times, returning an array of the results + * of each execution. The `iteratee` is bound to `thisArg` and invoked with * one argument; (index). * * @static * @memberOf _ * @category Utility - * @param {number} n The number of times to execute `iterator`. - * @param {Function} [iterator=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `iterator`. + * @param {number} n The number of times to execute `iteratee`. + * @param {Function} [iteratee=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. * @returns {Array} Returns the array of results. * @example * @@ -9135,18 +9135,18 @@ * _.times(3, function(n) { this.cast(n); }, mage); * // => also calls `mage.castSpell(n)` three times */ - function times(n, iterator, thisArg) { + function times(n, iteratee, thisArg) { n = nativeIsFinite(n = +n) && n > -1 ? n : 0; - iterator = baseCallback(iterator, thisArg, 1); + iteratee = baseCallback(iteratee, thisArg, 1); var index = -1, result = Array(nativeMin(n, MAX_ARRAY_LENGTH)); while (++index < n) { if (index < MAX_ARRAY_LENGTH) { - result[index] = iterator(index); + result[index] = iteratee(index); } else { - iterator(index); + iteratee(index); } } return result;