1.1.1 • Published 5 years ago

turtler v1.1.1

Weekly downloads
84
License
Apache-2.0
Repository
github
Last release
5 years ago

turtler

🐢 Ascii tables made easy

Npm Version Build Status Coverage Status Dependency Status devDependency Status npm npm

Installation

npm install turtler --save

Usage

the given options are the defaults

let table = new Turtler([
  ["uid", "name"],
  ["1", "Doe"],
  ["2", "Hemma"]
], {
  hasHeader: true,
  columnSeparator: ' | ',
  headerSeparator: '='
});

console.log(table);

This will yield:

uid | name
===========
1   | Doe  
2   | Hemma

Markdown

We can also output markdown tables just as easily

let table = new Turtler([
  ["uid", "name"],
  ["1", "Doe"],
  ["2", "Hemma"]
]);

console.log(table.markdown());

This will yield:

| uid | name  |
|-----|-------|
| 1   | Doe   |
| 2   | Hemma |

Html

We can also output html tables just as easily

let table = new Turtler([
  ["uid", "name"],
  ["1", "Doe"],
  ["2", "Hemma"]
]);

console.log(table.html());

This will yield:

<table>
  <thead>
    <tr>
      <th>uid</th>
      <th>name</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>Doe</td>
    </tr>
    <tr>
      <td>2</td>
      <td>Hemma</td>
    </tr>
  </tbody>
</table>