UNPKG

type-plus

Version:
12 lines 532 B
/** * Compose functions to produce a new function. * @params args functions to be composed. * Each function will receive the return value of the previous function as its parameters. * @return The composed function will expect the parameters of the first function, * and return the result of the last function. */ export function compose(...fns) { // eslint-disable-next-line @typescript-eslint/no-unsafe-return return (...args) => fns.reduce((args, fn) => [fn(...args)], args)[0]; } //# sourceMappingURL=compose.js.map