Created
September 12, 2014 00:28
-
-
Save bradparker/5622fef35db00f3159e5 to your computer and use it in GitHub Desktop.
Collection comparison helpers
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 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