mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
28 lines
818 B
JavaScript
28 lines
818 B
JavaScript
/**
|
|
* 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`.
|
|
*
|
|
* @private
|
|
* @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`.
|
|
* @returns {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
|
|
}
|
|
|
|
export default baseFor
|