mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Remove internal hasPath.
This commit is contained in:
@@ -1,39 +0,0 @@
|
|||||||
import castPath from './castPath.js'
|
|
||||||
import isArguments from '../isArguments.js'
|
|
||||||
import isIndex from './isIndex.js'
|
|
||||||
import isLength from '../isLength.js'
|
|
||||||
import toKey from './toKey.js'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if `path` exists on `object`.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {Object} object The object to query.
|
|
||||||
* @param {Array|string} path The path to check.
|
|
||||||
* @param {Function} hasFunc The function to check properties.
|
|
||||||
* @returns {boolean} Returns `true` if `path` exists, else `false`.
|
|
||||||
*/
|
|
||||||
function hasPath(object, path, hasFunc) {
|
|
||||||
path = castPath(path, object)
|
|
||||||
|
|
||||||
let index = -1
|
|
||||||
let { length } = path
|
|
||||||
let result = false
|
|
||||||
let key
|
|
||||||
|
|
||||||
while (++index < length) {
|
|
||||||
key = toKey(path[index])
|
|
||||||
if (!(result = object != null && hasFunc(object, key))) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
object = object[key]
|
|
||||||
}
|
|
||||||
if (result || ++index != length) {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
length = object == null ? 0 : object.length
|
|
||||||
return !!length && isLength(length) && isIndex(key, length) &&
|
|
||||||
(Array.isArray(object) || isArguments(object))
|
|
||||||
}
|
|
||||||
|
|
||||||
export default hasPath
|
|
||||||
Reference in New Issue
Block a user