1 function compose(...funcs) { 2 if (funcs.length === 0) { 3 return arg => arg 4 } 5 if (funcs.length === 1) { 6 return funcs[0] 7 } 8 return funcs.reduce((a, b) => (...args) => a(b(...args))) 9 }