1 var baseToPath = require('./baseToPath'),
2 isArguments = require('../isArguments'),
3 isArray = require('../isArray'),
4 isIndex = require('./isIndex'),
5 isKey = require('./isKey'),
6 isLength = require('../isLength'),
7 isString = require('../isString'),
8 last = require('../last'),
9 parent = require('./parent');
12 * Checks if `path` exists on `object`.
15 * @param {Object} object The object to query.
16 * @param {Array|string} path The path to check.
17 * @param {Function} hasFunc The function to check properties.
18 * @returns {boolean} Returns `true` if `path` exists, else `false`.
20 function hasPath(object, path, hasFunc) {
24 var result = hasFunc(object, path);
25 if (!result && !isKey(path)) {
26 path = baseToPath(path);
27 object = parent(object, path);
30 result = hasFunc(object, path);
33 return result || (isLength(object && object.length) && isIndex(path, object.length) &&
34 (isArray(object) || isString(object) || isArguments(object)));
37 module.exports = hasPath;