Skip to content

Instantly share code, notes, and snippets.

@Bear-Foot
Created April 1, 2016 23:41
Show Gist options
  • Save Bear-Foot/fe40b7644de21ca25cbec8a48dcf2252 to your computer and use it in GitHub Desktop.
Save Bear-Foot/fe40b7644de21ca25cbec8a48dcf2252 to your computer and use it in GitHub Desktop.
function arg1(arg){return arg === 1}
function arg2(arg){return arg !== 1}
function combineFilters(filters) {
return filters.reduce(function (prev, curr) {
return function (arg) {
return prev(arg) && curr(arg)
}
}, function (){return true})
}
console.log(combineFilters([arg2, arg1, arg1])(1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment