mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Bump to v4.7.0.
This commit is contained in:
18
_hasPath.js
18
_hasPath.js
@@ -4,9 +4,7 @@ var baseCastPath = require('./_baseCastPath'),
|
||||
isIndex = require('./_isIndex'),
|
||||
isKey = require('./_isKey'),
|
||||
isLength = require('./isLength'),
|
||||
isString = require('./isString'),
|
||||
last = require('./last'),
|
||||
parent = require('./_parent');
|
||||
isString = require('./isString');
|
||||
|
||||
/**
|
||||
* Checks if `path` exists on `object`.
|
||||
@@ -24,10 +22,16 @@ function hasPath(object, path, hasFunc) {
|
||||
var result = hasFunc(object, path);
|
||||
if (!result && !isKey(path)) {
|
||||
path = baseCastPath(path);
|
||||
object = parent(object, path);
|
||||
if (object != null) {
|
||||
path = last(path);
|
||||
result = hasFunc(object, path);
|
||||
|
||||
var index = -1,
|
||||
length = path.length;
|
||||
|
||||
while (object != null && ++index < length) {
|
||||
var key = path[index];
|
||||
if (!(result = hasFunc(object, key))) {
|
||||
break;
|
||||
}
|
||||
object = object[key];
|
||||
}
|
||||
}
|
||||
var length = object ? object.length : undefined;
|
||||
|
||||
Reference in New Issue
Block a user