mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
633 B
26 lines
633 B
10 years ago
|
/**
|
||
9 years ago
|
* Creates a base function for methods like `_.forIn`.
|
||
10 years ago
|
*
|
||
|
* @private
|
||
|
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||
|
* @returns {Function} Returns the new base function.
|
||
|
*/
|
||
|
function createBaseFor(fromRight) {
|
||
|
return function(object, iteratee, keysFunc) {
|
||
9 years ago
|
var index = -1,
|
||
|
iterable = Object(object),
|
||
10 years ago
|
props = keysFunc(object),
|
||
9 years ago
|
length = props.length;
|
||
10 years ago
|
|
||
9 years ago
|
while (length--) {
|
||
|
var key = props[fromRight ? length : ++index];
|
||
10 years ago
|
if (iteratee(iterable[key], key, iterable) === false) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return object;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
module.exports = createBaseFor;
|