Skip to content

Instantly share code, notes, and snippets.

@sushiljainam
Last active December 27, 2016 11:08
Show Gist options
  • Save sushiljainam/29b74d5aaf6905a2939feabbc69f544d to your computer and use it in GitHub Desktop.
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
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)};
@sushiljainam
Copy link
Author

for full source: gist.github.com/sushiljainam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment