Last active
December 27, 2016 11:08
-
-
Save sushiljainam/29b74d5aaf6905a2939feabbc69f544d to your computer and use it in GitHub Desktop.
object as filter to filter array of objects returning array of lesser objects: minified
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
Array.prototype.pushUnique=function(t){-1==this.indexOf(t)&&this.push(t)},Array.prototype.filterAny=function(t,n){var r=[];return this.forEach(function(n){for(var i in t)n[i]==t[i]&&r.pushUnique(n)}),"function"!=typeof n?r:void n(r)},Array.prototype.filterAll=function(t,n){var r=[];return this.forEach(function(n){var i=0;for(var o in t)n[o]==t[o]&&i++,i==Object.keys(t).length&&r.pushUnique(n)}),"function"!=typeof n?r:void n(r)}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for full source: gist.github.com/sushiljainam