Skip to content

Instantly share code, notes, and snippets.

@samdelagarza
Created January 9, 2013 21:32
Show Gist options
  • Save samdelagarza/4497144 to your computer and use it in GitHub Desktop.
Save samdelagarza/4497144 to your computer and use it in GitHub Desktop.
Underscore helpers
__without:function (list, othersList) {
var diff = _.chain(list)
.filter(function (item) {
return _.where(othersList,
{Name:item.Name}).length === 0;
})
.value();
return diff;
},
__filter:function (l, o) {
var same = _.chain(l)
.filter(function (item) {
return _.where(o, {Name:item.Name}).length > 0;
})
.value();
return same;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment