Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Helpers to see if object has all props or any of the props
const hasAllProps = function(list, within) {
list.forEach(function(e) {
if (!within.hasOwnProperty(e) || within[e] == "") {
return false;
}
});
return true;
};
const hasAnyProps = function(list, within) {
let found = false;
list.forEach(function(e) {
if (within.hasOwnProperty(e) && within[e]) {
found = true;
}
});
return found;
};
module.exports = {
hasAllProps,
hasAnyProps
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment