API Reference

Takes a list of functions and returns a single function that executes all of the provided functions in order on the input and returns the final result..

type GenericFunction<T> = (...args: T[]) => unknown

function createPipe<T>(
  ...funcs: [
    firstFunc: GenericFunction<T>,
    secondFunc: GenericFunction<T>,
    ...otherFuncs: GenericFunction<T>[]
  ]
)

// Example:

const double = (n: number) => n * 2
const triple = (n: number) => n * 3
const doubleThenTriple = createPipe(double, triple)

doubleThenTriple(6) //=> 36