@donothing/boxxy
v1.0.1
Published
A JavaScript box drawing library for ASCII art layouts with CSV table converter
Downloads
9
Maintainers
Readme
Boxxy - JavaScript Box Drawing Library
A JavaScript library for creating ASCII art layouts and tables, translated from OCaml. Perfect for creating formatted console output, tables, and text-based user interfaces. Includes a CLI tool for converting CSV data to ASCII tables.
Features
- Box Creation: Create boxes from strings, characters, or filled with patterns
- Layout Management: Stack boxes horizontally and vertically with alignment options
- Table Generation: Convert data arrays into formatted ASCII tables
- CSV CLI Tool: Pipe CSV data directly to create ASCII tables
- Framing: Add borders and frames around content
- Flexible Alignment: Support for left, center, and right alignment
Quick Start
import { printBox, framed, fromString, makeTableFromCsv } from './index.js';
// Create a simple framed box
const box = framed(fromString("Hello, World!"));
printBox(box);
// Create a table from CSV data
const csvData = [
['Name', 'Age', 'City'],
['Alice', '30', 'New York'],
['Bob', '25', 'Chicago']
];
const table = makeTableFromCsv(csvData);
printBox(table);CLI Usage
Convert CSV data to ASCII tables by piping to the boxxy command:
# From a CSV file
cat data.csv | npx boxxy
# From inline data
echo 'Name,Age,City
Alice,30,New York
Bob,25,Los Angeles' | npx boxxy
# With tab-separated values
cat data.tsv | npx boxxy
# Get help
npx boxxy --help
# Get version
npx boxxy --versionCLI Options
-h, --help- Show help message and usage examples-v, --version- Display version information
Testing
# Test CSV converter
npm run test-csvAPI Reference
Core Functions
fromString(s)- Create a box from a stringfill(char, height, width)- Create a filled boxbeside(left, right, align?)- Stack boxes horizontallyabove(top, bottom, align?)- Stack boxes verticallyframed(box)- Add a frame around a boxmakeTableFromCsv(csvData)- Create a table from CSV data arraymakeTableFromCsv(csvData)- Create a table from CSV data (array of arrays)
Alignment Options
HorizontalAlign.LEFT,HorizontalAlign.CENTER,HorizontalAlign.RIGHTVerticalAlign.TOP,VerticalAlign.CENTER,VerticalAlign.BOTTOM
Example Output
$ echo 'Product,Price,Rating
Laptop,999.99,4.5
Coffee Mug,12.50,4.8' | npx boxxy
.------------------------------.
| Product | Price | Rating |
|------------|--------|--------|
| Laptop | 999.99 | 4.5 |
| Coffee Mug | 12.50 | 4.8 |
'------------------------------'License
MIT
