Skip to content

Instantly share code, notes, and snippets.

@olecksamdr
Created June 12, 2020 08:56
Show Gist options
  • Save olecksamdr/6738ffc45123eeee42cac862e17582e9 to your computer and use it in GitHub Desktop.
Save olecksamdr/6738ffc45123eeee42cac862e17582e9 to your computer and use it in GitHub Desktop.
const allIsTrue = R.curry((predicates, object) =>
Object.key(predicates).reduce((acc, key) => {
const predicate = predicates[key];
const predicateType = typeof predicate;
const value = object[key];
const valueType = typeof value;
if (predicateType === 'function') {
return predicate(value);
}
if (predicateType === 'object' && valueType === 'object') {
return allIsTrue(predicate, value);
}
return false;
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment