Removed modules/contrib/media module to allow update to the core media module
[yaffs-website] / node_modules / uncss / node_modules / lodash / internal / hasPath.js
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');
10
11 /**
12  * Checks if `path` exists on `object`.
13  *
14  * @private
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`.
19  */
20 function hasPath(object, path, hasFunc) {
21   if (object == null) {
22     return false;
23   }
24   var result = hasFunc(object, path);
25   if (!result && !isKey(path)) {
26     path = baseToPath(path);
27     object = parent(object, path);
28     if (object != null) {
29       path = last(path);
30       result = hasFunc(object, path);
31     }
32   }
33   return result || (isLength(object && object.length) && isIndex(path, object.length) &&
34     (isArray(object) || isString(object) || isArguments(object)));
35 }
36
37 module.exports = hasPath;