mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Finish renaming iteratee to iterable. [closes #170]
Former-commit-id: 0ac6cecaec0a779cb29c21b5fc3caa90c84479eb
This commit is contained in:
16
build.js
16
build.js
@@ -1479,10 +1479,10 @@
|
|||||||
' return object;',
|
' return object;',
|
||||||
' }',
|
' }',
|
||||||
' for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {',
|
' for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {',
|
||||||
' var iteratee = arguments[argsIndex];',
|
' var iterable = arguments[argsIndex];',
|
||||||
' if (iteratee) {',
|
' if (iterable) {',
|
||||||
' for (var key in iteratee) {',
|
' for (var key in iterable) {',
|
||||||
' object[key] = iteratee[key];',
|
' object[key] = iterable[key];',
|
||||||
' }',
|
' }',
|
||||||
' }',
|
' }',
|
||||||
' }',
|
' }',
|
||||||
@@ -1524,11 +1524,11 @@
|
|||||||
' return object;',
|
' return object;',
|
||||||
' }',
|
' }',
|
||||||
' for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {',
|
' for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {',
|
||||||
' var iteratee = arguments[argsIndex];',
|
' var iterable = arguments[argsIndex];',
|
||||||
' if (iteratee) {',
|
' if (iterable) {',
|
||||||
' for (var key in iteratee) {',
|
' for (var key in iterable) {',
|
||||||
' if (object[key] == null) {',
|
' if (object[key] == null) {',
|
||||||
' object[key] = iteratee[key];',
|
' object[key] = iterable[key];',
|
||||||
' }',
|
' }',
|
||||||
' }',
|
' }',
|
||||||
' }',
|
' }',
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
'isArguments',
|
'isArguments',
|
||||||
'isArray',
|
'isArray',
|
||||||
'isString',
|
'isString',
|
||||||
'iteratee',
|
'iterable',
|
||||||
'length',
|
'length',
|
||||||
'nativeKeys',
|
'nativeKeys',
|
||||||
'object',
|
'object',
|
||||||
|
|||||||
@@ -261,8 +261,8 @@
|
|||||||
'var argsIndex = 0,\n' +
|
'var argsIndex = 0,\n' +
|
||||||
" argsLength = typeof guard == 'number' ? 2 : arguments.length;\n" +
|
" argsLength = typeof guard == 'number' ? 2 : arguments.length;\n" +
|
||||||
'while (++argsIndex < argsLength) {\n' +
|
'while (++argsIndex < argsLength) {\n' +
|
||||||
' if ((iteratee = arguments[argsIndex])) {',
|
' if ((iterable = arguments[argsIndex])) {',
|
||||||
'loop': 'result[index] = iteratee[index]',
|
'loop': 'result[index] = iterable[index]',
|
||||||
'bottom': ' }\n}'
|
'bottom': ' }\n}'
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@
|
|||||||
'args': 'collection, callback, thisArg',
|
'args': 'collection, callback, thisArg',
|
||||||
'top': "callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg)",
|
'top': "callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg)",
|
||||||
'arrays': "typeof length == 'number'",
|
'arrays': "typeof length == 'number'",
|
||||||
'loop': 'if (callback(iteratee[index], index, collection) === false) return result'
|
'loop': 'if (callback(iterable[index], index, collection) === false) return result'
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Reusable iterator options for `forIn` and `forOwn` */
|
/** Reusable iterator options for `forIn` and `forOwn` */
|
||||||
@@ -415,7 +415,7 @@
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Object} [options1, options2, ...] The compile options object(s).
|
* @param {Object} [options1, options2, ...] The compile options object(s).
|
||||||
* arrays - A string of code to determine if the iteratee is an array or array-like.
|
* arrays - A string of code to determine if the iterable is an array or array-like.
|
||||||
* useHas - A boolean to specify using `hasOwnProperty` checks in the object loop.
|
* useHas - A boolean to specify using `hasOwnProperty` checks in the object loop.
|
||||||
* args - A string of comma separated arguments the iteration function will accept.
|
* args - A string of comma separated arguments the iteration function will accept.
|
||||||
* top - A string of code to execute before the iteration branches.
|
* top - A string of code to execute before the iteration branches.
|
||||||
@@ -433,7 +433,7 @@
|
|||||||
'shadowed': shadowed,
|
'shadowed': shadowed,
|
||||||
|
|
||||||
// iterator options
|
// iterator options
|
||||||
'arrays': 'isArray(iteratee)',
|
'arrays': 'isArray(iterable)',
|
||||||
'bottom': '',
|
'bottom': '',
|
||||||
'loop': '',
|
'loop': '',
|
||||||
'top': '',
|
'top': '',
|
||||||
@@ -476,19 +476,19 @@
|
|||||||
* @returns {Array|Object|String} Returns `collection`.
|
* @returns {Array|Object|String} Returns `collection`.
|
||||||
*/
|
*/
|
||||||
var each = function (collection, callback, thisArg) {
|
var each = function (collection, callback, thisArg) {
|
||||||
var index, iteratee = collection, result = collection;
|
var index, iterable = collection, result = collection;
|
||||||
if (!collection) return result;
|
if (!collection) return result;
|
||||||
callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg);
|
callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg);
|
||||||
var length = iteratee.length; index = -1;
|
var length = iterable.length; index = -1;
|
||||||
if (typeof length == 'number') {
|
if (typeof length == 'number') {
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
if (callback(iteratee[index], index, collection) === indicatorObject) return result
|
if (callback(iterable[index], index, collection) === indicatorObject) return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (index in iteratee) {
|
for (index in iterable) {
|
||||||
if (hasOwnProperty.call(iteratee, index)) {
|
if (hasOwnProperty.call(iterable, index)) {
|
||||||
if (callback(iteratee[index], index, collection) === indicatorObject) return result;
|
if (callback(iterable[index], index, collection) === indicatorObject) return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -635,12 +635,12 @@
|
|||||||
* // => alerts 'name' and 'bark' (order is not guaranteed)
|
* // => alerts 'name' and 'bark' (order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
var forIn = function (collection, callback) {
|
var forIn = function (collection, callback) {
|
||||||
var index, iteratee = collection, result = collection;
|
var index, iterable = collection, result = collection;
|
||||||
if (!collection) return result;
|
if (!collection) return result;
|
||||||
callback || (callback = identity);
|
callback || (callback = identity);
|
||||||
|
|
||||||
for (index in iteratee) {
|
for (index in iterable) {
|
||||||
if (callback(iteratee[index], index, collection) === indicatorObject) return result;
|
if (callback(iterable[index], index, collection) === indicatorObject) return result;
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
};
|
};
|
||||||
@@ -666,13 +666,13 @@
|
|||||||
* // => alerts '0', '1', and 'length' (order is not guaranteed)
|
* // => alerts '0', '1', and 'length' (order is not guaranteed)
|
||||||
*/
|
*/
|
||||||
var forOwn = function (collection, callback) {
|
var forOwn = function (collection, callback) {
|
||||||
var index, iteratee = collection, result = collection;
|
var index, iterable = collection, result = collection;
|
||||||
if (!collection) return result;
|
if (!collection) return result;
|
||||||
callback || (callback = identity);
|
callback || (callback = identity);
|
||||||
|
|
||||||
for (index in iteratee) {
|
for (index in iterable) {
|
||||||
if (hasOwnProperty.call(iteratee, index)) {
|
if (hasOwnProperty.call(iterable, index)) {
|
||||||
if (callback(iteratee[index], index, collection) === indicatorObject) return result;
|
if (callback(iterable[index], index, collection) === indicatorObject) return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@@ -808,10 +808,10 @@
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {
|
for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {
|
||||||
var iteratee = arguments[argsIndex];
|
var iterable = arguments[argsIndex];
|
||||||
if (iteratee) {
|
if (iterable) {
|
||||||
for (var key in iteratee) {
|
for (var key in iterable) {
|
||||||
object[key] = iteratee[key];
|
object[key] = iterable[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -880,11 +880,11 @@
|
|||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {
|
for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {
|
||||||
var iteratee = arguments[argsIndex];
|
var iterable = arguments[argsIndex];
|
||||||
if (iteratee) {
|
if (iterable) {
|
||||||
for (var key in iteratee) {
|
for (var key in iterable) {
|
||||||
if (object[key] == null) {
|
if (object[key] == null) {
|
||||||
object[key] = iteratee[key];
|
object[key] = iterable[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2049,7 +2049,7 @@
|
|||||||
* // => [4, 5, 2, 3, 0, 1]
|
* // => [4, 5, 2, 3, 0, 1]
|
||||||
*/
|
*/
|
||||||
function reduceRight(collection, callback, accumulator, thisArg) {
|
function reduceRight(collection, callback, accumulator, thisArg) {
|
||||||
var iteratee = collection,
|
var iterable = collection,
|
||||||
length = collection ? collection.length : 0,
|
length = collection ? collection.length : 0,
|
||||||
noaccum = arguments.length < 3;
|
noaccum = arguments.length < 3;
|
||||||
|
|
||||||
@@ -2061,8 +2061,8 @@
|
|||||||
forEach(collection, function(value, index, collection) {
|
forEach(collection, function(value, index, collection) {
|
||||||
index = props ? props[--length] : --length;
|
index = props ? props[--length] : --length;
|
||||||
accumulator = noaccum
|
accumulator = noaccum
|
||||||
? (noaccum = false, iteratee[index])
|
? (noaccum = false, iterable[index])
|
||||||
: callback(accumulator, iteratee[index], index, collection);
|
: callback(accumulator, iterable[index], index, collection);
|
||||||
});
|
});
|
||||||
return accumulator;
|
return accumulator;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user