Add iteratee arity hints to forEach methods. [closes #2277]

This commit is contained in:
John-David Dalton
2016-04-23 11:29:52 -07:00
parent 43c26b5d6f
commit fbc91cf7ae
3 changed files with 44 additions and 20 deletions

View File

@@ -8500,9 +8500,8 @@
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
*/
function forEach(collection, iteratee) {
return (typeof iteratee == 'function' && isArray(collection))
? arrayEach(collection, iteratee)
: baseEach(collection, getIteratee(iteratee));
var func = isArray(collection) ? arrayEach : baseEach;
return func(collection, getIteratee(iteratee, 3));
}
/**
@@ -8526,9 +8525,8 @@
* // => Logs `2` then `1`.
*/
function forEachRight(collection, iteratee) {
return (typeof iteratee == 'function' && isArray(collection))
? arrayEachRight(collection, iteratee)
: baseEachRight(collection, getIteratee(iteratee));
var func = isArray(collection) ? arrayEachRight : baseEachRight;
return func(collection, getIteratee(iteratee, 3));
}
/**
@@ -12103,7 +12101,7 @@
function forIn(object, iteratee) {
return object == null
? object
: baseFor(object, getIteratee(iteratee), keysIn);
: baseFor(object, getIteratee(iteratee, 3), keysIn);
}
/**
@@ -12135,7 +12133,7 @@
function forInRight(object, iteratee) {
return object == null
? object
: baseForRight(object, getIteratee(iteratee), keysIn);
: baseForRight(object, getIteratee(iteratee, 3), keysIn);
}
/**
@@ -12167,7 +12165,7 @@
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
*/
function forOwn(object, iteratee) {
return object && baseForOwn(object, getIteratee(iteratee));
return object && baseForOwn(object, getIteratee(iteratee, 3));
}
/**
@@ -12197,7 +12195,7 @@
* // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
*/
function forOwnRight(object, iteratee) {
return object && baseForOwnRight(object, getIteratee(iteratee));
return object && baseForOwnRight(object, getIteratee(iteratee, 3));
}
/**