00001 var isArrayLike = require('./isArrayLike'); 00002 00011 function createBaseEach(eachFunc, fromRight) { 00012 return function(collection, iteratee) { 00013 if (collection == null) { 00014 return collection; 00015 } 00016 if (!isArrayLike(collection)) { 00017 return eachFunc(collection, iteratee); 00018 } 00019 var length = collection.length, 00020 index = fromRight ? length : -1, 00021 iterable = Object(collection); 00022 00023 while ((fromRight ? index-- : ++index < length)) { 00024 if (iteratee(iterable[index], index, iterable) === false) { 00025 break; 00026 } 00027 } 00028 return collection; 00029 }; 00030 } 00031 00032 module.exports = createBaseEach;