Book Image

Mastering JavaScript Functional Programming

By : Federico Kereki
Book Image

Mastering JavaScript Functional Programming

By: Federico Kereki

Overview of this book

Functional programming is a programming paradigm for developing software using functions. Learning to use functional programming is a good way to write more concise code, with greater concurrency and performance. The JavaScript language is particularly suited to functional programming. This book provides comprehensive coverage of the major topics in functional programming with JavaScript to produce shorter, clearer, and testable programs. You’ll delve into functional programming; including writing and testing pure functions, reducing side-effects, and other features to make your applications functional in nature. Specifically, we’ll explore techniques to simplify coding, apply recursion for loopless coding, learn ways to achieve immutability, implement design patterns, and work with data types. By the end of this book, you’ll have developed the JavaScript skills you need to program functional applications with confidence.
Table of Contents (22 chapters)
Title Page
About the Author
About the Reviewer
Customer Feedback
Connecting Functions - Pipelining and Composition
Answers to Questions

Chapter 8. Connecting Functions - Pipelining and Composition

In Chapter 7, Transforming Functions - Currying and Partial Application, we saw several different ways to build new functions by applying higher-order functions. In this chapter, we will go to the core of FP and see how to create sequences of function calls, so their combination will produce a more complex result out of several simpler components. We will include the following:

  • Pipelining, a way to join functions together in similar way to Unix/Linux pipes
  • Chaining, which may be considered a variant of pipelining, but restricted to objects
  • Composing, which is a classic operation with its origins in basic computer theory

Along the way, we will be touching on related concepts, such as the following:

  • Pointfree style, which is often used with pipelining and composition
  • Debugging of composed or piped functions, for which we'll whip up some auxiliary tools
  • Testing of composed or piped functions, which won't prove to be of high complexity