Utilities

In the next group of modules, we will look at utilities. The functions chosen here are used across many different types of applications. We will cover everything from events and cryptology to buffers and npm.

Events

Events are used in many built-in Node objects. This is because emitting and listening for events is the perfect way to let another function know when to start executing. This is especially true in the asynchronous world of Node.js. Anytime we use the on function of an object, it means that it has inherited from EventEmitter. All of the examples will assume that the events variable is already created as follows:

var events = require('events');

EventEmitter

This is the parent class that can be inherited from to create a new EventEmitter ...

Get Web Developer's Reference Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.