Shell scripting with Node.js
You can buy the offline version of this book (HTML, PDF, EPUB, MOBI) and support the free online version.
(Ad, please don’t block.)

2 Instructions

This chapter contains information that is useful when reading this book.

2.1 How to read this book

There are two ways in which you can read this book:

This book was written with both ways in mind, so skipping content should not be a problem. If, at any point, there is relevant information elsewhere in the book, I point to it.

2.2 How assertions are used in this book

The following import is always assumed to have been made (similarly to how non-strict assert is available in the Node.js REPL):

import * as assert from 'node:assert/strict';

This module implements assertions – which are often used in examples in this book. This is what they look like:

// Comparing primitive values:
assert.equal(3 + 4, 7);
assert.equal('abc'.toUpperCase(), 'ABC');

// Comparing objects:
assert.notEqual({prop: 1}, {prop: 1}); // shallow comparison
assert.deepEqual({prop: 1}, {prop: 1}); // deep comparison
assert.notDeepEqual({prop: 1}, {prop: 2}); // deep comparison