Skip to content

Instantly share code, notes, and snippets.

@bradparker
Created September 12, 2014 00:28
Show Gist options
  • Save bradparker/5622fef35db00f3159e5 to your computer and use it in GitHub Desktop.
Save bradparker/5622fef35db00f3159e5 to your computer and use it in GitHub Desktop.
Collection comparison helpers
function allInCollection (collection) {
return function (subCollection) {
return subCollection.every(function (subItem) {
return collection.some(function (item) {
return item.id === subItem.id;
});
});
};
}
function inCollection (collection) {
return function (compItem) {
return collection.some(function (item) {
return item.id === compItem.id;
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment