Created
February 14, 2016 18:13
-
-
Save derhuerst/9b7c450fef49b80036d0 to your computer and use it in GitHub Desktop.
fp helpers in JS ✨
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 bind = function () { | |
var args = Array.from(arguments) | |
var fn = args.shift() | |
return function () { | |
return fn(...args.concat(Array.from(arguments))) | |
} | |
} |
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 compose = function () { | |
var fns = Array.from(arguments).reverse() | |
var first = fns.shift() | |
return function () { | |
return fns.reduce(function (result, fn) { | |
return fn(result) | |
}, first(...arguments)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment