1 var castPath = require('./_castPath'),
2 isArguments = require('./isArguments'),
3 isArray = require('./isArray'),
4 isIndex = require('./_isIndex'),
5 isKey = require('./_isKey'),
6 isLength = require('./isLength'),
7 toKey = require('./_toKey');
10 * Checks if `path` exists on `object`.
13 * @param {Object} object The object to query.
14 * @param {Array|string} path The path to check.
15 * @param {Function} hasFunc The function to check properties.
16 * @returns {boolean} Returns `true` if `path` exists, else `false`.
18 function hasPath(object, path, hasFunc) {
19 path = isKey(path, object) ? [path] : castPath(path);
25 while (++index < length) {
26 var key = toKey(path[index]);
27 if (!(result = object != null && hasFunc(object, key))) {
32 if (result || ++index != length) {
35 length = object == null ? 0 : object.length;
36 return !!length && isLength(length) && isIndex(key, length) &&
37 (isArray(object) || isArguments(object));
40 module.exports = hasPath;