concept reusable code module in category data

appears as: reusable code modules, reusable code module
Data Wrangling with JavaScript

This is an excerpt from Manning's book Data Wrangling with JavaScript.

A Node.js project can contain any number of JavaScript files that are either entry points (runnable from the command line), reusable code modules, or possibly both (which can be useful for testing your code). By convention, the main entry point is normally called index.js.

Listing 2.6 The generateReport function is moved to a reusable code module
"use strict";

function generateReport (data) {
    const columns = Object.keys(data[0]);
    return {
        numRows: data.length,
        numColumns: columns.length,
        columnNames: columns,
    };
};

module.exports = generateReport;    #1  

#1   Exports the function so that it can be reused in other code modules