From c594bda77f0f8b5172c84e5bee490403335cb6e3 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Sat, 28 Mar 2015 23:54:24 -0400 Subject: [PATCH] Simplify `getProperty` and friends. --- lodash.src.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index bd774bb95..5876702cf 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -2600,7 +2600,7 @@ function basePropertyDeep(path) { return function(object) { - return object == null ? undefined : getPath(object, path); + return getProperty(object, path); }; } @@ -4056,16 +4056,16 @@ var index = -1, length = path.length; - while (++index < length) { + while (object != null && ++index < length) { object = object[path[index]]; - if (object == null) { - return object; - } } return object; } function getProperty(object, path) { + if (object == null) { + return undefined; + } return isKey(path) ? object[path] : getPath(object, toPath(path)); } @@ -11256,7 +11256,7 @@ */ function propertyOf(object) { return function(path) { - return object == null ? undefined : getProperty(object, path); + return getProperty(object, path); }; }