Skip to Content
Mastering JavaScript Functional Programming
book

Mastering JavaScript Functional Programming

by Federico Kereki
November 2017
Intermediate to advanced
386 pages
9h 22m
English
Packt Publishing
Content preview from Mastering JavaScript Functional Programming

Using other constructs

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering JavaScript Functional Programming - Second Edition

Mastering JavaScript Functional Programming - Second Edition

Federico Kereki

Publisher Resources

ISBN: 9781787287440Supplemental Content