pipe.mjs 292 B

1234567891011
  1. /**
  2. * Pipe
  3. * Compose other transformers to run linearily
  4. * pipe(min(20), max(40))
  5. * @param {...functions} transformers
  6. * @return {function}
  7. */
  8. const combineFunctions = (a, b) => (v) => b(a(v));
  9. const pipe = (...transformers) => transformers.reduce(combineFunctions);
  10. export { pipe };