Glossary

Chapter 1

abstract interface

A programmatic description of an API that doesn’t include an implementation. In Node.js, a good example is the Streams API.

arrow function

A function written in a shorthand syntax. Instead of writing function () {}, write () => {} when passing functions as arguments to other functions. If the function accepts only one argument, the parentheses can be omitted.

asynchronous

Describes code that doesn’t necessarily run in the order in which it appears. In Node.js, this term is used to distinguish APIs that accept callbacks that will be run at a point in the future. For example, fs.readFile accepts a callback that receives the file’s contents after it has been read.

core modules

The libraries that are built into Node.

destructuring

ECMAScript 2015 introduced destructuring, which allows objects and arrays to be broken into variables and constants. For example, const { name } = { name: 'Alex' } creates a constant called name with the value alex.

ECMAScript standard

ECMAScript is a scripting language specification standardized by Ecma International. There are several ECMAScript standards; this book focuses on ECMAScript 2015 (ECMAScript 6th Edition). JavaScript implementers use the ECMAScript standard to make sure their interpreter is compatible with JavaScript written for other implementations.

event

A string that causes a function to be called. The function is known as an object listener. An emitter sends the named event. The basic class for creating emitters in Node is EventEmitter.

event loop

Node’s event loop waits for external events and converts them into callback invocations. Other systems use similar things-—message dispatchers and run loops—to quickly route events to the corresponding event handler.

JSON (JavaScript Object Notation)

JSON is a lightweight data-interchange format, intended to be easy to read and write, and based on a subset of JavaScript.

libuv

A multiplatform library for asynchronous I/O. It’s used in Node, but also other libraries and languages such as Julia.

nonblocking I/O

Blocking operations halt execution until the operation completes. Node uses nonblocking I/O, which means reads from a network or file resource won’t block execution.

npm

Node’s package manager. It allows you to install Node packages from a large central repository and to manage dependencies in Node projects.

Promise

The Promise object is a standardized ECMAScript 2015 API for representing values that may be available now, in the future, or never.

REPL (read-eval-print loop)

A command-line interface enabling you to evaluate code and see the results.

rest parameters

The rest parameter syntax in ECMAScript 2015 allows an unknown number of arguments in a function to be represented as an array. To name two arguments but put the rest in an array, use function (a, b, ...rest). It can also be used with destructuring to copy objects: const newObject = { ...oldObject }.

semantic versioning

A convention for specifying library compatibility using three numbers: major, minor, and patch, written as 1.0.2 (major: 1, minor: 0, patch: 2). An application that depends on version 1.0.2 should be compatible with 1.1.1, but not 2.0.0.

Chapter 2

callback

A function that has been passed to a function and may run later.

closure

JavaScript functions capture the variables defined in their enclosing scope. If you define function B inside function A, B will have access to all of A’s values.

CommonJS module specification

A module format for defining which values should be exported from the current JavaScript file. See module.

content management system (CMS)

Web application used to edit text and images that will be displayed on a public-facing website.

flow control (or control flow)

The order in which statements will be executed. Because Node is asynchronous, control flow is of interest, as JavaScript offers many ways of dealing with control flow, including callbacks, promises, generators, basic looping primitives, and iterators. In Node, flow control refers to the way we group sequences of asynchronous tasks.

global scope

Scope means the parts of the program that can access a value, so global scope means a value is accessible everywhere within a program.

module

Node modules are single files that contain JavaScript. Values (typically, functions and constants) can be exported so they can be used in other files.

nested callback

A callback within a callback; when a callback has been passed to a function, it’s sometimes necessary to define another callback inside the first callback.

package.json

A file that defines a Node project’s name, author, license, and dependencies. Every Node program and library you create should have a package.json file.

property

JavaScript objects are collections of keys and values, and keys and values are known as the object’s properties.

stack trace

A list of program instructions that had executed up to the point when an error occurred.

state

The value of all the variables in a program at a given time.

Chapter 3

boilerplate

Code that’s frequently duplicated and that could be automated.

client-side bundle

Preprocessed JavaScript code from several source files that’s usually minified and compressed, and then served to clients.

cURL

A command-line tool and programmer library for making HTTP requests. It’s often used as a debugging tool for quickly checking how web servers respond to requests.

database model

A programmer-friendly data model that makes it easier to interact with database tables or documents than using the database’s native language.

form encoding

When an HTTP POST is made to a web server, including a simple form POST, the form’s contents are encoded into the request body. The most common format, application/x-www-form-urlencoded, is similar to URL encoding, which replaces unsafe ASCII characters with percent signs.

MIME (Multipurpose Internet Mail Extensions)

An internet standard for adding nontextual data to emails and multipart message bodies. This allows email clients to show HTML, images, and text in non-ASCII character sets.

object-relational mapping (ORM)

A library that maps between programmer-friendly data structures (for example, JavaScript objects) and database data structures (for example, tables and foreign keys).

REST (Representational State Transfer), RESTful API

Stateless web API using a set of predefined operations in HTTP. The operations are based on HTTP verbs; the most common are GET, POST, PUT, and DELETE.

route

The URL fragment and HTTP verb that a given route handler should process.

route handler

A user-defined callback that runs when an HTTP request is made to a web application. The route handler usually generates content, perhaps from a database, or modifies a database, and then generates the response by using a template or format such as JSON.

static asset

A file that’s served by a web server without any additional processing. Typically, images, CSS files, and client-side JavaScript files are static assets.

template

Plain-text format that can include embedded data or JavaScript code and be used to generate HTML to streamline HTML’s syntax.

Chapter 4

build system

A set of tools and configuration files for generating JavaScript that will run efficiently in a browser.

linter

A program that checks the correctness of a source file’s format. Linters can be used to enforce a given programming style on a project by checking against a set of linting rules.

method chain

Running a method on the return value of a previously called method.

pipe

Connecting a data output to an input. In UNIX, processes are pipelined by using the vertical bar character (|); in Node, streams are connected by using method chaining.

source map

A file that allows browser debuggers to map from a line in a transpiled source file to the original code.

stream

An efficient data input and/or output channel that may be text or binary data. Node supports readable, writable, and other stream types, and these streams can be linked together by using pipes.

test runner

A program that runs and collates the results of unit tests found in one or more files.

transpile

Also known as source-to-source compilers, JavaScript transpilers convert one type of ECMAScript to another. The most common use is to convert modern ES2015 to backward-compatible ECMAScript 5, which can run in more browsers. Another example is TypeScript, which is a superset of JavaScript that gets transpiled into ES5 or ES2015.

webpack loader

Transforms or transpiles source code.

webpack plugin

Changes the behavior of the build process itself, rather than the output files.

Chapter 5

database adapter

Some database libraries are written in a generic fashion and can be extended with specific adapters that implement functionality for the desired database.

decoupled

If a function, class, or module can easily be changed in a project, or reused in another project, then it is loosely coupled.

full-stack framework

A framework that includes features for working with both client-side and server-side code. That usually means it has libraries for dealing with HTTP requests, request routing, database modeling, and communication with code running in a browser.

GET parameters

URL parameters that appear after a question mark and are separated by ampersands.

HTTP verb

The HTTP method (GET, POST, PUT, PATCH, DELETE) representing the action that should be performed on a remote resource.

isomorphic

JavaScript applications that run both client-side and server-side by sharing the same code.

middleware

Functions that can be called in sequence to modify an HTTP request and response.

Model-View-Controller (MVC)

Design pattern for separating software into components; the model manages data and logic, the view transforms the data into a user interface, and the controller converts interactions into operations for the model or view.

relational database

A database structure based around relations between the stored entities.

single-page web app

An application that’s served to the browser once and doesn’t require a full-page reload. If the application needs to change the URL in the browser for any reason, the HTML5 History API is used to give the impression that the URL has changed and the browser has loaded a new page from the server.

web framework

A set of libraries for developing a web application with support for extensibility through plugins or middleware.

Chapter 6

bcrypt

A password-hashing function. This function maps arbitrary amounts of data to a string of fixed size that can be stored safely in a database, so the user’s plain-text password isn’t stored.

content negotiation

Part of the HTTP standard that deals with serving different versions of a document at the same URI. User agents (browsers) can request a different data format if the server supports it.

CSS preprocessor

Programs that convert supersets of CSS to CSS that a browser can interpret. The Sass and LESS stylesheet languages both include CSS preprocessors, and these languages add features such as variables, nesting, and mixins.

password salt

Random data used in addition to the input of a hash function, making dictionary attacks harder.

Redis database

An in-memory database that’s also used as a cache and message broker. It’s useful for storing user sessions and dealing with push messages in web applications.

Redis hash

A map from a string field and a value, used to represent objects in a Redis database.

response object

An object that determines how your server will respond to a given HTTP request. It includes the response body, which is usually a web page, and the headers.

single-threaded

A running program (process) can be made up of threads that execute concurrently. JavaScript’s model is to use a single thread, but allow the thread to switch context and run different code when events happen. The events in a browser are interactions such as the user clicking a button; in Node, they’re typically I/O events, such as network operations or data being read from a disk.

template language

Lightweight markup languages that are converted to HTML and add features that make it easier to inject values from code, and iterate over arrays or objects.

third-party middleware

Middleware components that aren’t distributed by the authors of the original web library or framework.

Chapter 7

lexical scope

The visibility of a variable is determined by its scope. In JavaScript, adding a function adds a new level of scope. Any variables defined in that function are visible by any functions defined within that function.

mixin

This usually means a class that contains methods for use in other classes. In Sass, mixins are groups of CSS declarations that can be reused in multiple places; in Pug, mixins are used to define reusable template fragments.

partial

Small, reusable template.

section lambda

A lambda is an anonymous function, so a section lambda in Hogan is a way of associating a function with a tag in a template.

significant whitespace

In JavaScript, curly brackets, semicolons, and newlines are used to separate statements. If a new lexical block is required, a function or control statement is used. In languages with significant whitespace, such as Pug, lines of code are grouped together by the number of spaces used to indent each line.

XSS (cross-site scripting) attack

If a web application accepts user input from forms or URL parameters, and those values are redisplayed in templates, then it may be possible to inject malicious code. Values must be escaped first to be safe from this type of attack.

Chapter 8

ACID (atomicity, consistency, isolation, durability)

For a database to be ACID-compliant, it must support operations that are atomic (the operation succeeds, or the operation fails and the database is left unchanged), consistent (the data changes only in the allowed ways), isolated (ensuring concurrent execution), and durable (after a change has been made, it will remain, even if the system crashes or is rebooted).

BSON

A binary format used by MongoDB for representing objects. Objects consist of an ordered set of elements; the elements are made up of a field name, a type, and a value. The types supported by BSON include string, integer, date, and JavaScript code.

daemon

A program that runs in the background, usually starting automatically when the system boots.

database schema

A formal definition of the data and relationships between items in a database. It’s the design of the database.

database transaction

One or more database operations that are grouped together and run according to the ACID properties.

distributed database

A database stored on multiple computers, potentially but not necessarily in different geographical locations.

leaky abstraction

An attempt to hide complexity that exposes too many details and issues of the underlying implementation.

document-oriented database

A database that stores semistructured data without a predefined schema, sometimes in JSON or XML. Examples include MongoDB and CouchDB.

memoize

An optimization technique that stores the result of a function so it doesn’t have to be called again.

NoSQL

A database that doesn’t use tabular relations as found in relational databases.

primary key

A column in a database table that’s used to uniquely identify each row.

publish-subscribe

A pattern in which messages can be sent to multiple receivers.

query builder

An API that’s more convenient for programmers than writing SQL queries by hand.

relational algebra

Used as the theoretical basis for relational databases to model the stored data and queries that can be performed on it.

replica set

A group of MongoDB processes that maintain the same dataset.

web worker

A way of allowing JavaScript to run on background threads in browsers.

Chapter 9

assert, assertion

Ensure that an expression matches an expectation. This can be a simple Boolean statement, equality, or practically anything else. In Node, assertions throw exceptions when they fail. A test runner can catch and collate these exceptions to produce test reports.

BDD (behavior-driven development)

An extension of TDD that uses a different API style to encourage a focus on where in the process the test occurs, what to test and what not to test, and how much to test in one go. It also tries to improve understanding of test failures, and the naming of test units.

functional testing

Testing a slice of functionality through the whole system. In web development, that means full-stack testing: the browser and server are tested at the same time.

mocks

Objects or values that behave like real counterparts, but are usually a simple veneer that provides just enough behavior to allow a test to run. Rather than accessing real files or networks in tests, which could be slow or dangerous if destructive operations occur, mocks can be used to safely simulate their behavior.

test-driven development (TDD)

Writing tests before the code under test.

test runner

A program that manages loading tests, running them, and then collecting the results so they can be displayed. Mocha is a test runner.

typeof

A JavaScript operator that returns a string for a given object or value.

unit testing

Small parts of a module, such as functions or methods of a class, are tested in isolation against assertions in small test cases (units).

Chapter 10

Amazon EC2 (Amazon Elastic Compute Cloud)

Amazon’s virtual computer service.

container

A type of virtualization, containers are isolated user-space instances of an operating system, running on top of a host operating system. Containers offer additional control over resource usage and security benefits, and they can be quickly started up and destroyed.

Content delivery network (CDN)

Distributed servers that deliver static content.

Docker image

An image of the filesystem that Docker will use to create a container.

dyno

Heroku’s term for a container; this is used to run both servers and arbitrary commands in an isolated environment on Heroku’s servers.

Elastic Beanstalk

An orchestration service run by Amazon for scripting deployments to Amazon’s other services, such as EC2.

log rotation

A command that runs periodically and renames log files based on the date, and then optionally compresses them to use less storage space.

SSH (Secure Shell)

Provides an encrypted command-line (or X11) interface to a remote computer for running commands. It can form the workflow of a web developer when initially configuring a new server, or connecting to servers to run maintenance or debugging commands.

sudo

A program for running programs with other user privileges. It’s usually used to run commands that need special privileges, such as editing system configuration files.

Chapter 11

arguments

Program arguments are the flags provided on the command line that enable or disable certain features.

exit status

Value returned by a program when it completes. Nonzero values indicate an error.

interprocess communication

The methods an operating system provides to allow running programs to communicate. An example is pipes, which use the output of one program as the input of another, but even files can be considered a form of interprocess communication.

Open Group

A consortium that publishes the Single UNIX Specification, a family of standards that qualifies producers of operating systems to use the UNIX trademark.

shell

Command-line user interface enabling commands to be entered and the results viewed. It’s called a shell because it’s a layer around the operating system.

redirection

Capturing the output from a program and sending it as input to another program or file.

stderr

The error stream for outputting error messages from a running program.

stdin

The input stream for a running program.

stdout

The output stream for messages printed by a program.

Chapter 12

Chromium

An open source browser from which Google’s Chrome browser derives its code.

Electron main process

A Node process that manages the Electron app and access to files and the network.

Electron render process

The Chromium web view.

JSX

React applications use a mix of HTML fragments alongside JavaScript. This is preprocessed into pure JavaScript before it runs in a browser. This language is called JSX.

native

A program or library that’s written using the operating system’s built-in APIs.

React

A library by Facebook for building data-driven web and mobile user interfaces.

Appendix A

constructor

A function that creates and initializes a JavaScript object.

CSV (comma-separated values)

A text format for tabular data that’s typically used with databases or spreadsheet programs. The values are split into columns by using commas, and rows by using new lines.

DOM (Document Object Model)

The standards that define the API for JavaScript working with HTML. The DOM is a language-independent interface working with HTML.

microformats

A way of including structured data in HTML that’s readable by both humans and software. Because HTML doesn’t always represent structured data clearly, microformats can be used to embed data such as addresses, geographical locations, and calendar entries in HTML without any special tags.

regular expression

An expression that matches patterns in a string.

robots.txt

A standard used by websites to tell web crawlers and scrapers what content can be scanned or excluded from scraping.

vertical search engine

Search engine that focuses on a niche.

web scraping

Converting HTML into structured data that can be stored in files or a database.

XPath

A query language for selecting nodes from an XML document.