Chapter 9

Event-Driven Programming and Built-In Modules

Learning Objectives

By the end of this chapter, you will be able to:

  • Use event modules in Node.js
  • Create an event emitter to enhance the functionality of existing code
  • Build custom event emitters
  • Use built-in modules and utilities
  • Implement a timer module to get an API to schedule timer functions

In this chapter, we will use event emitters and built-in modules to avoid creating projects with deeply coupled dependencies.


In the previous chapter, we talked about how event-driven programming is used in Node.js and how we can modify normal callback-based async operations to use async-await and promises. We know that the Node.js core API is built on async-driven architecture. ...

Get Professional JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.