Skip to content

Instantly share code, notes, and snippets.

@sergueyarellano
Created May 26, 2021 14:24
Show Gist options
  • Save sergueyarellano/cb183a2b23d0228b24e9f6b1d0c44995 to your computer and use it in GitHub Desktop.
Save sergueyarellano/cb183a2b23d0228b24e9f6b1d0c44995 to your computer and use it in GitHub Desktop.
function complyWith (input, restrictions) {
const formattedRestrictions = substituteOperators(restrictions)
return formattedRestrictions.every(applyOperator(input))
}
function applyOperator (input) {
return restriction => {
const value = input[restriction.property]
return restriction.operator(value, restriction.value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment