Skip to content

Instantly share code, notes, and snippets.

@pedrouid
Created November 6, 2017 18:05
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 pedrouid/ba930f2416d028b5200e508b8951eae2 to your computer and use it in GitHub Desktop.
Save pedrouid/ba930f2416d028b5200e508b8951eae2 to your computer and use it in GitHub Desktop.
Crawl a nested object to find data
// Crawl nested object and find data that matches your __CONDITION__
const crawlObject = (evalObj, prevObj, prevKey) => {
if (typeof evalObj === "object") {
Object.keys(evalObj).map((key) => crawlObject(evalObj[key], evalObj, key));
} else {
if (__CONDITION__) {
// DO SOMETHING
console.log(prevObj[prevKey])
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment