ortense
7/24/2017 - 5:25 PM

simple and small compose function

simple and small compose function

const compose = (...fns) => 
  fns.reduce((f, g) => (...args) => f(g(...args)))

/*
const a = x => `a(${x})`
const b = x => `b(${x})`
const c = x => `c(${x})`

const composed = compose(a, b, c) 
composed('x') // a(b(c(x)))
*/