MCPcopy Create free account
hub / github.com/RubyLouvre/anu / hasPath

Function hasPath

test/babel.js:28524–28543  ·  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 `false`.

(object, path, hasFunc)

Source from the content-addressed store, hash-verified

28522 * @returns {boolean} Returns `true` if `path` exists, else `false`.
28523 */
28524 function hasPath(object, path, hasFunc) {
28525 path = castPath(path, object);
28526
28527 var index = -1,
28528 length = path.length,
28529 result = false;
28530
28531 while (++index < length) {
28532 var key = toKey(path[index]);
28533 if (!(result = object != null && hasFunc(object, key))) {
28534 break;
28535 }
28536 object = object[key];
28537 }
28538 if (result || ++index != length) {
28539 return result;
28540 }
28541 length = object == null ? 0 : object.length;
28542 return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object));
28543 }
28544
28545 module.exports = hasPath;
28546

Callers 2

hasFunction · 0.85
hasInFunction · 0.85

Calls 6

castPathFunction · 0.85
toKeyFunction · 0.85
isLengthFunction · 0.85
isIndexFunction · 0.85
isArrayFunction · 0.85
isArgumentsFunction · 0.85

Tested by

no test coverage detected