Chapter 6. Advanced applications of function types
This chapter covers
- Using a simplified decorator pattern
- Implementing a resumable counter
- Handling long-running operations
- Writing clean asynchronous code by using promises and async/await
In chapter 5, we covered the basics of function types and scenarios enabled by the ability to treat functions like other values by passing them as arguments and returning them as results. We also looked at some powerful abstractions that implement common data processing patterns: map(), filter(), and reduce().
In this chapter, we’ll continue our discussion of function types with some more advanced applications. We’ll start by looking at the decorator pattern, its by-the-book implementation, and an alternative ...