Skip to content

dep-ts/table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@dep/table 📊

Tiny table builder for any format — text, HTML, CSV, Markdown, JSON, or custom outputs.

JSR version


Features ✨

  • 🧱 Build tables row-by-row using a fluent API
  • 📜 Output to text, HTML, CSV, JSON, or Markdown
  • 🧩 Extend with custom builders via callback functions
  • 💥 Type-safe errors and validation through TableError
  • 🪶 Lightweight, dependency-free, and works in Deno, Node.js, or browser ESM

Installation 📦

Deno

import { Builder, Csv, Html, Json, Markdown, Text } from "jsr:@dep/table";

Node.js (18+) or Browsers

npx jsr add @dep/table

Then import as an ES module:

import { Builder, Csv, Html, Json, Markdown, Text } from "@dep/table";

Usage 🎯

Basic Builder

import { Builder } from "@dep/table";

const table = new Builder()
  .add("Name", "Age")
  .add("Alice", 30)
  .add("Bob", 25)
  .build();

console.log(table);
// [["Name","Age"],["Alice",30],["Bob",25]]

CSV Output

import { Csv } from "@dep/table";

const csv = new Csv().add("Name", "Age").add("Alice", 30).build();

console.log(csv);
// "Name","Age"\n"Alice","30"

HTML Output

import { Html } from "@dep/table";

const html = new Html().add("Product", "Price").add("Apple", 1.99).build();

console.log(html);
// "<table><tr><td>Product</td><td>Price</td></tr><tr><td>Apple</td><td>1.99</td></tr></table>"

Markdown Output

import { Markdown } from "@dep/table";

const md = new Markdown().add("Name", "Age").add("Lila", 3).build();

console.log(md);
/*
| Name | Age |
| ---- | --- |
| Lila | 3   |
*/

Custom Output

import { Custom } from "@dep/table";

const xml = new Custom(
  (rows) =>
    `<root>${rows.map((r) => `<row>${r.join("")}</row>`).join("")}</root>`,
  "data.xml",
)
  .add("Name", "Age")
  .add("Zoe", 21)
  .build();

console.log(xml);
// "<root><row>NameAge</row><row>Zoe21</row></root>"

License 📄

MIT License – see LICENSE for details.

Author: Estarlin R. — estarlincito.com

About

Tiny table builder for any format — text, HTML, CSV, Markdown, JSON, or custom outputs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published