Skip to content

Instantly share code, notes, and snippets.

@hperantunes
Last active May 8, 2019 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hperantunes/1458e7988b12819fa8fb2833e20cc6eb to your computer and use it in GitHub Desktop.
Save hperantunes/1458e7988b12819fa8fb2833e20cc6eb to your computer and use it in GitHub Desktop.
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