Skip to content

Instantly share code, notes, and snippets.

@amnuts
Created October 6, 2020 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amnuts/47c2d874aebb37cdb49e5b7897840414 to your computer and use it in GitHub Desktop.
Save amnuts/47c2d874aebb37cdb49e5b7897840414 to your computer and use it in GitHub Desktop.
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