November 2017
Intermediate to advanced
386 pages
9h 22m
English
If we think in functional terms, what we have is a list of functions and we want to apply them sequentially, starting with the first, then applying the second to whatever the first function produced as its result, and then applying the third to the second function's results, and so on. If we were just fixing a pipeline of two functions, this could do:
const pipeTwo = (f, g) => (...args) => g(f(...args));
This is not so useless as it may seem because we can compose longer pipelines -- though, I'll admit, it requires too much writing! We can write our three functions' pipeline in two different, equivalent ways:
const countOdtFiles3 = path => pipeTwo(pipeTwo(getDir, filterOdt), count)(path);const countOdtFiles4 = path ...