Created
April 14, 2017 03:06
-
-
Save alexmaze/5dd7bd38e50153690a01bbe36e456e20 to your computer and use it in GitHub Desktop.
search object contents
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
function search(obj: Object, query: string) { | |
for (let key of Object.getOwnPropertyNames(obj)) { | |
if (RegExp(query, 'i').test(obj[key])) { | |
return true | |
} | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment