Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / internal / createForEach.js
1 var bindCallback = require('./bindCallback'),
2     isArray = require('../lang/isArray');
3
4 /**
5  * Creates a function for `_.forEach` or `_.forEachRight`.
6  *
7  * @private
8  * @param {Function} arrayFunc The function to iterate over an array.
9  * @param {Function} eachFunc The function to iterate over a collection.
10  * @returns {Function} Returns the new each function.
11  */
12 function createForEach(arrayFunc, eachFunc) {
13   return function(collection, iteratee, thisArg) {
14     return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
15       ? arrayFunc(collection, iteratee)
16       : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
17   };
18 }
19
20 module.exports = createForEach;