Remove baseForOwn from several modules.

This commit is contained in:
John-David Dalton
2017-03-04 23:26:27 -08:00
parent 17f7069d07
commit 3c2795b816
8 changed files with 31 additions and 28 deletions

View File

@@ -1,6 +1,3 @@
import baseFindKey from './.internal/baseFindKey.js'
import baseForOwn from './.internal/baseForOwn.js'
/**
* This method is like `find` except that it returns the key of the first
* element `predicate` returns truthy for instead of the element itself.
@@ -24,7 +21,18 @@ import baseForOwn from './.internal/baseForOwn.js'
* // => 'barney' (iteration order is not guaranteed)
*/
function findKey(object, predicate) {
return baseFindKey(object, predicate, baseForOwn)
let result
if (object == null) {
return result
}
Object.keys(object).some((key) => {
const value = object[key]
if (predicate(value, key, object)) {
result = value
return true
}
})
return result
}
export default findKey