UNPKG

foop

Version:

interfaces that describe their intentions.

30 lines (27 loc) 849 B
/** * The base implementation of `baseForOwn` which iterates over `object` * properties returned by `keysFunc` and invokes `iteratee` for each property. * Iteratee functions may exit iteration early by explicitly returning `false`. * @since 5.0.0-beta.6 * @memberOf loop * * @param {Object} object The object to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {Function} keysFunc The function to get the keys of `object`. * @return {Object} Returns `object`. * */ function baseFor(object, iteratee, keysFunc) { const iterable = Object(object) const props = keysFunc(object) let {length} = props let index = -1 while (length--) { const key = props[++index] if (iteratee(iterable[key], key, iterable) === false) { break } } return object } module.exports = baseFor