Created
November 26, 2014 13:00
-
-
Save alexeyraspopov/614d30634ba197912170 to your computer and use it in GitHub Desktop.
This file contains 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
var slice = Array.prototype.slice.call.bind(Array.prototype.slice); | |
function use(fn, fns){ | |
return function(){ | |
var args = slice(arguments); | |
return fn.apply(null, args.map(function(arg, index){ | |
return fns[index](arg); | |
})); | |
} | |
} | |
function pipe(f, g){ | |
return function(a){ | |
return g(f(a)); | |
}; | |
} | |
function eq(a){ | |
return function(b){ | |
return a === b; | |
}; | |
} | |
function get(prop){ | |
return function(target){ | |
return target[prop]; | |
}; | |
} | |
var propEq = use(pipe, [get, eq]); | |
console.log( propEq('complete', true)({complete:true}) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment