Created
October 26, 2016 17:14
-
-
Save thecodeite/4e1fdc5c62c2fbca85afde5556f2d9a0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function deepFind (predicate, data) { | |
if (!predicate || !data) return null | |
if (typeof data === 'object') { | |
for (let k in data) { | |
let x = data[k] | |
if (x && predicate(x)) return x | |
let r = deepFind(predicate, x) | |
if (r) return r | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment