3种方式
1.loop
take a set of functions,make it into an array ,you loop over that array,
each time you call a function you capture the result and that becomes the input of the next
2.recursion
3.reduce

pipe 实现

形如 pipe(f1,f2,f3)(4) 被执行为 f1(f2(f3(4)))

  1. function pipe(...fns) {
  2. return function piped(result){
  3. var list = [...fns];
  4. while (list.length > 0) {
  5. // take the first function from the list
  6. // and execute it
  7. result = list.shift()( result );
  8. }
  9. return result;
  10. };
  11. }

这里