Registry / data / easy-table

easy-table

JSON →
library0.0.4jsnpmunverified

easy-table is a JavaScript utility for rendering plain text tables primarily for command-line interfaces. It allows for highly customizable table structures, including dynamic cell content formatting via 'printer' functions, column sorting with specific syntax, and aggregation features like totaling and averaging. The package is currently at version 1.2.0. Its last known activity on npm was 5 years ago, and the GitHub repository shows an 8-year inactivity period, suggesting it is in an abandoned state rather than actively maintained. It ships with TypeScript type definitions, enabling type-safe usage in modern TypeScript projects. Key differentiators include its flexible cell rendering pipeline and built-in aggregation capabilities for simple CLI reporting.

npm install easy-table
INSTALL
IMPORT
SIG · EASY-TABLE
E
easy-table
datajavascriptv0.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Table (CommonJS)
const Table = require('easy-table')
Primary CommonJS import pattern shown in documentation.
Table (ESM)
import Table from 'easy-table'
import { Table } from 'easy-table'
The package uses a CommonJS default export, which translates to a default import in ESM. Named imports like `import { Table }` will result in errors in strict ESM environments.
Table.print
import Table from 'easy-table'; Table.print(data)
import { print } from 'easy-table'; print(data)
Static methods like `print` and helper functions like `number` are accessed as properties of the main `Table` export, not as named exports directly.

Demonstrates basic table creation, custom cell formatting, static `Table.print` usage with options, and sorting and totaling features.

import Table from 'easy-table'; const data = [ { id: 123123, desc: 'Something awesome', price: 1000.00 }, { id: 245452, desc: 'Very interesting book', price: 11.45}, { id: 232323, desc: 'Yet another product', price: 555.55 } ]; // Using instance methods for fine-grained control let t = new Table(); data.forEach(product => { t.cell('Product Id', product.id); t.cell('Description', product.desc); t.cell('Price, USD', product.price, Table.number(2)); // Format price to 2 decimal places t.newRow(); }); console.log('Formatted Table:\n' + t.toString()); // Using the static print method for quick rendering with options console.log('\nAuto-generated Table with options:\n' + Table.print(data, { desc: { name: 'Product Description' }, // Rename column price: { printer: Table.number(2) } // Apply printer })); // Example of sorting and totaling let sortableTable = new Table(); data.forEach(product => { sortableTable.cell('Product Id', product.id); sortableTable.cell('Description', product.desc); sortableTable.cell('Price, USD', product.price); sortableTable.newRow(); }); sortableTable.sort(['Price, USD|des']); // Sort by Price descending sortableTable.total('Price, USD', { printer: Table.aggr.printer('Total: ', Table.number(2)) }); console.log('\nSorted and Totaled Table:\n' + sortableTable.toString());
Debug
Known issues
breakingThe package appears to be abandoned, with no new features, bug fixes, or security updates for over 5 years. Relying on it for critical applications may pose risks.
fix
Consider migrating to a more actively maintained library for text table rendering if new features, bug fixes, or security updates are required.
affects: >=1.2.0
gotchaThe package primarily uses CommonJS module syntax (`require`). While it ships with TypeScript types, direct ESM `import { Table } from 'easy-table'` will likely fail in strict ESM environments because it's a default export from a CommonJS module.
fix
Use `import Table from 'easy-table'` for ESM projects to correctly import the default export. For CommonJS, `const Table = require('easy-table')` is correct.
affects: >=1.0.0
gotchaCustom cell 'printer' functions require explicit handling of the `width` parameter for correct padding. If `width` is not handled, content might not be correctly aligned or truncated when the library calculates layout.
fix
Ensure custom printer functions accept both `value` and `width` parameters and use `Table.padLeft` or `Table.padRight` with `width` if alignment is desired, as shown in the documentation example for `currency`.
affects: >=1.0.0
gotchaSorting columns by string-based syntax (e.g., `['Column Name|des']`) is specific and can be prone to typos. No validation is provided for column names or sort orders (e.g., 'des' vs 'descending').
fix
Carefully check column names and use the exact `|asc` or `|des` suffixes. For complex sorting, consider providing a custom comparator function to `t.sort()`.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Table is not a constructor
Attempting to instantiate `Table` using an incorrect import, typically `import { Table } from 'easy-table'` instead of `import Table from 'easy-table'` in ESM, or `require('easy-table').Table` in CommonJS if it's a default export.
fix
For ESM, use `import Table from 'easy-table'`. For CommonJS, ensure you're doing `const Table = require('easy-table')` if `Table` is the default/module.exports object.
TypeError: t.cell is not a function
`t` is not an instance of `Table`. This often happens if `new Table()` was not called, or the import of `Table` was incorrect, resulting in `t` being undefined or an unexpected object.
fix
Ensure `let t = new Table()` is called after correctly importing `Table`.
ReferenceError: require is not defined
Attempting to use `require('easy-table')` in an ECMAScript Module (ESM) context (e.g., a file with `"type": "module"` in `package.json` or a `.mjs` file).
fix
Switch to ESM import syntax: `import Table from 'easy-table'`. If you must use `require` in an ESM file, Node.js v22+ has some experimental support, or consider `await import('easy-table')` for older versions, or explicitly configure `type: 'commonjs'` in your `package.json`.
Table does not sort correctly or throws an error for column 'XYZ'
The string passed to `t.sort(['Column Name'])` does not exactly match a column name or uses an invalid sort order suffix (e.g., 'asc' vs 'ass').
fix
Verify that the column name string passed to `t.sort()` is an exact match for one of the column headers used in `t.cell()`. Ensure sort order suffixes are strictly `|asc` or `|des`.
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
easy-table — npm install easy-table · libregistry