Format JavaScript Standard Style as Stylish (i.e. snazzy) output
94
Build a simple tool that formats structured data into aligned, readable tables for terminal output.
Your tool should accept an array of data rows where each row is an array of values. It should output a formatted table where columns are properly aligned and spaced.
Input format:
Output format:
Column alignment:
@generates
Create a function formatTable(rows, options) that:
Input:
const rows = [
['100', '5', 'First row'],
['2', '300', 'Second row'],
['3000', '1', 'Third row']
];
formatTable(rows, { align: ['', 'r', 'l'] });Expected output (note the alignment):
100 5 First row
2 300 Second row
3000 1 Third row/**
* Formats an array of rows into an aligned table string
* @param {Array<Array<string>>} rows - Array of rows, each row is an array of column values
* @param {Object} options - Formatting options
* @param {Array<string>} options.align - Array of alignment strings: '' (none), 'r' (right), 'l' (left)
* @returns {string} Formatted table string with aligned columns
*/
function formatTable(rows, options) {
// Implementation here
}
module.exports = { formatTable };Provides table formatting with column alignment support.
Removes ANSI color codes from strings to calculate accurate visual widths.
Install with Tessl CLI
npx tessl i tessl/npm-snazzydocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10