mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Bump to v3.6.0.
This commit is contained in:
20
internal/createForEach.js
Normal file
20
internal/createForEach.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import bindCallback from './bindCallback';
|
||||
import isArray from '../lang/isArray';
|
||||
|
||||
/**
|
||||
* Creates a function for `_.forEach` or `_.forEachRight`.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} arrayFunc The function to iterate over an array.
|
||||
* @param {Function} eachFunc The function to iterate over a collection.
|
||||
* @returns {Function} Returns the new each function.
|
||||
*/
|
||||
function createForEach(arrayFunc, eachFunc) {
|
||||
return function(collection, iteratee, thisArg) {
|
||||
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
|
||||
? arrayFunc(collection, iteratee)
|
||||
: eachFunc(collection, bindCallback(iteratee, thisArg, 3));
|
||||
};
|
||||
}
|
||||
|
||||
export default createForEach;
|
||||
Reference in New Issue
Block a user