Created
June 12, 2020 08:56
-
-
Save olecksamdr/6738ffc45123eeee42cac862e17582e9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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