Skip to content

Commit

Permalink
Remove side effects of getObjectPropertyValue method
Browse files Browse the repository at this point in the history
  • Loading branch information
PKief committed Feb 23, 2020
1 parent 44f0031 commit c803b43
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/helpers/objects.ts
Expand Up @@ -14,15 +14,17 @@ export const getObjectPropertyValue = (obj: Object, path: string) => {
return object === Object(object);
};

let result = JSON.parse(JSON.stringify(obj));

for (let i = 0; i < pathArray.length; ++i) {
const k = pathArray[i];
if (isObject(obj) && k in obj) {
obj = obj[k];
if (isObject(result) && k in result) {
result = result[k];
} else {
return;
}
}
return obj;
return result;
};

/**
Expand Down

0 comments on commit c803b43

Please sign in to comment.