Created
November 6, 2017 18:05
-
-
Save pedrouid/ba930f2416d028b5200e508b8951eae2 to your computer and use it in GitHub Desktop.
Crawl a nested object to find data
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
// 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