MCPcopy Create free account
hub / github.com/deployd/deployd / hasPath

Function hasPath

test-app/public/sinon.js:16750–16770  ·  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

(object, path, hasFunc)

Source from the content-addressed store, hash-verified

16748 * @returns {boolean} Returns `true` if `path` exists, else `false`.
16749 */
16750 function hasPath(object, path, hasFunc) {
16751 path = castPath(path, object);
16752
16753 var index = -1,
16754 length = path.length,
16755 result = false;
16756
16757 while (++index < length) {
16758 var key = toKey(path[index]);
16759 if (!(result = object != null && hasFunc(object, key))) {
16760 break;
16761 }
16762 object = object[key];
16763 }
16764 if (result || ++index != length) {
16765 return result;
16766 }
16767 length = object == null ? 0 : object.length;
16768 return !!length && isLength(length) && isIndex(key, length) &&
16769 (isArray(object) || isArguments(object));
16770 }
16771
16772 /**
16773 * Initializes an array clone.

Callers 2

hasFunction · 0.85
hasInFunction · 0.85

Calls 6

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

Tested by

no test coverage detected