1.0.0 • Published 1 year ago

@nacho-cs/md-table v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

md-table

a lightweight package to generate tables in markdown from matrices

to add

  • first install the package using npm, the add it using the ESM syntax (import)
  • commonJS syntax is not supported (require)
import mdTable from "@nacho-cs/md-table";

to use

import mdTable from "@nacho-cs/md-table";
const labels = ["Fruits", "Vegetables"];
const data = [
  ["Bananas", "Carrots"],
  ["Oranges", "Tomatoes"],
];
const table = mdTable(labels, data);
console.log(table);
// | Fruits  | Vegetables |
// |---------|------------|
// | Bananas | Carrots    |
// | Oranges | Tomatoes   |
  • the first parameter for mdTable is the label for the table
  • in this case, the labels are Fruits and Vegetables
  • the second parameter is for the data
  • the data is a matrix that represents the actual table (Bananas, Carrots, Oranges, and Tomatoes are the data in this case)