
Table-console is a JavaScript library that displays dynamic, clean, and customizable tables in your console log. It provides customizable borders, text styling, and alignment options.
It’s useful for debugging, data analysis, and presenting structured information. Web developers can use it to organize API responses, configuration settings, or performance metrics in the browser’s console log.
How to use it:
1. Install table-console with NPM:
npm install table-console
2. Import the Table module into your project file:
import Table from 'table-console';
// OR
var Table = require("table-console");3. Create a new Table instance. This is where you’ll customize the table’s appearance:
var myTable = new Table({
style: "unicode", // or "unicode bold", 'unicode double', 'ascii'
padding: 1,
leftPadding: 1,
rightPadding: 1,
horizontalLines: true,
headerLine: true,
borders: { // custom table borders
topLeft: "┌", top: "─", topMid: "┬", topRight: "┐",
midLeft: "├", mid: "─", midMid: "┼", midRight: "┤",
botLeft: "└", bot: "─", botMid: "┴", botRight: "┘",
sep: "│",
}
});4. Add your tabular data using the insertRows method:
myTable.insertRows([ ['jQueryScript', '.Net'], ['CSSScript', '.Com'] ]);
5. Print the table in your console log.
console.log(myTable.toString());
6. Here is a set of API methods for further manipulation:
// Adds a single row. insertRow(row) // Deletes a row. removeRow(row) // Retrieves all rows. getRows() // Returns a string representation of the table. toString() // Adds a horizontal line. insertHorizontalLine() // Fetches a specific cell's value. getCell(rowId, colId) // Modifies a cell's content. setCell(rowId, colId, value) // Customizes cell attributes (e.g., color, alignment). // attributes: // color - string - black, red, green, yellow, blue, magenta, cyan, white, gray, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite // bgColor - string - black, red, green, yellow, blue, magenta, cyan, white, gray, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite // decorations - Array - bold, dim, italic, underline, overline, inverse, strikethrough, slowBlink, rapidBlink // align - string - left, center, right setCellAttrs(rowId, colId, attrs) // Applies attributes to an entire row. setRowAttrs(rowId, attrs) // Applies attributes to an entire column. setColAttrs(colId, attrs)







