Skip to content

Instantly share code, notes, and snippets.

@thecodeite
Created October 26, 2016 17:14
Show Gist options
  • Save thecodeite/4e1fdc5c62c2fbca85afde5556f2d9a0 to your computer and use it in GitHub Desktop.
Save thecodeite/4e1fdc5c62c2fbca85afde5556f2d9a0 to your computer and use it in GitHub Desktop.
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