MCPcopy
hub / github.com/lodash/lodash / hasPath

Function hasPath

lodash.js:6214–6234  ·  view source on GitHub ↗

* 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 `fa

(object, path, hasFunc)

Source from the content-addressed store, hash-verified

6212 * @returns {boolean} Returns `true` if `path` exists, else `false`.
6213 */
6214 function hasPath(object, path, hasFunc) {
6215 path = castPath(path, object);
6216
6217 var index = -1,
6218 length = path.length,
6219 result = false;
6220
6221 while (++index < length) {
6222 var key = toKey(path[index]);
6223 if (!(result = object != null && hasFunc(object, key))) {
6224 break;
6225 }
6226 object = object[key];
6227 }
6228 if (result || ++index != length) {
6229 return result;
6230 }
6231 length = object == null ? 0 : object.length;
6232 return !!length && isLength(length) && isIndex(key, length) &&
6233 (isArray(object) || isArguments(object));
6234 }
6235
6236 /**
6237 * Initializes an array clone.

Callers 2

hasFunction · 0.85
hasInFunction · 0.85

Calls 4

castPathFunction · 0.85
toKeyFunction · 0.85
isLengthFunction · 0.85
isIndexFunction · 0.85

Tested by

no test coverage detected