I love the concept of functional programming. Lately, in addition to my work with React + Redux +JS, etc. I have worked also a lot with the ClojureScript (I was warned that after I will start writing in any dialect of Clojure I will start thinking slightly different about functional programming, not I see that this is true).
(def output-data (function4 (function3 (function2 (function1 input-data)))))
let outputData = function4(function3(function2(function4(inputData))));
So, I was thinking of how this case can be written in a more readable way. Looking deeply and trying to understand what exactly happened with data in this process, I understood that we actually are trying to apply to reduce to this data but in a little bit unusual way. The statement above can be written like:
let outputData = [function1, function2, function3, function4]
.reduce((acc, step) => step(acc), inputData);
Now, for me, it looks more logical if we want to change now how the data is transformed we should just add/remove a pure function from the array of the modifiers, that will be applied to data.