Skip to content

Instantly share code, notes, and snippets.

@derhuerst
Created February 14, 2016 18:13
Show Gist options
  • Save derhuerst/9b7c450fef49b80036d0 to your computer and use it in GitHub Desktop.
Save derhuerst/9b7c450fef49b80036d0 to your computer and use it in GitHub Desktop.
fp helpers in JS ✨
var bind = function () {
var args = Array.from(arguments)
var fn = args.shift()
return function () {
return fn(...args.concat(Array.from(arguments)))
}
}
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