compose Posted on 2019-09-28 Edited on 2019-10-16 In JavaScript 123456789101112131415161718/** * * @param {...fn||arg} fns from right to left */function compose(...fns) { return function(x) { return fns.reduceRight((arg, fn) => fn(arg), x); };}/** * * @param {...fn||arg} fns from left to right */function pipe(...fns) { return function(x) { return fns.reduce((arg, fn) => fn(arg), x); };}