Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
JavaScript function composition: What’s the big deal? (jrsinclair.com)
2 points by fagnerbrack on May 24, 2022 | hide | past | favorite | 1 comment


If you need an async one: pipe(a, b, c) is equivalent to a().then(b).then(c)

  function pipe(...functions) {
    (async () => {
      let accum;
      for (const fn of functions)
        accum = await fn(accum);
    }());
  }




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: