Skip to content

Commit

Permalink
fix(get): remove object checks
Browse files Browse the repository at this point in the history
Remove all the checks for objects because they aren't
needed because has checks if the path exists therefore
if it doesn't it wont reach the checks
  • Loading branch information
Sean Hamilton committed Dec 5, 2018
1 parent 79f6f1c commit 6124905
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,9 @@ function get(object, path, defaultValue = undefined) {

// for each path parts from the parsed path
getPathParts(path).forEach((key) => {
// if the current value is an object and it isn't empty
if (is(currentValue) && !empty(currentValue)) {
// set the currentValue as the value from the key
currentValue = currentValue[key];
}
currentValue = currentValue[key];
});

// if the currentValue is undefined after getting the new
// value from the paths return the default value
if (currentValue === undefined) {
return defaultValue;
}

// if it isn't undefined return the value
return currentValue;
}
Expand Down

0 comments on commit 6124905

Please # to comment.