Simplify getProperty and friends.

This commit is contained in:
Justin Ridgewell
2015-03-28 23:54:24 -04:00
committed by jdalton
parent 8218b74fb3
commit c594bda77f

View File

@@ -2600,7 +2600,7 @@
function basePropertyDeep(path) { function basePropertyDeep(path) {
return function(object) { return function(object) {
return object == null ? undefined : getPath(object, path); return getProperty(object, path);
}; };
} }
@@ -4056,16 +4056,16 @@
var index = -1, var index = -1,
length = path.length; length = path.length;
while (++index < length) { while (object != null && ++index < length) {
object = object[path[index]]; object = object[path[index]];
if (object == null) {
return object;
}
} }
return object; return object;
} }
function getProperty(object, path) { function getProperty(object, path) {
if (object == null) {
return undefined;
}
return isKey(path) ? object[path] : getPath(object, toPath(path)); return isKey(path) ? object[path] : getPath(object, toPath(path));
} }
@@ -11256,7 +11256,7 @@
*/ */
function propertyOf(object) { function propertyOf(object) {
return function(path) { return function(path) {
return object == null ? undefined : getProperty(object, path); return getProperty(object, path);
}; };
} }