Last active
May 8, 2019 15:38
-
-
Save hperantunes/1458e7988b12819fa8fb2833e20cc6eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const findInObject = (combinedPath, object, separator = ".") => { | |
if (combinedPath === undefined) { | |
return undefined; | |
} | |
const path = combinedPath.split(separator); | |
return path.reduce((accumulator, value) => ((accumulator && accumulator[value] !== undefined) ? accumulator[value] : undefined), object); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment