tablifier
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

Tablifier

npm version License: MIT

With Tablifier, you can effortlessly create tables from arrays of data, customize column headers, align content, and apply formatting options to suit your needs. Whether you're working on data visualization, reporting, or any other application requiring tabular representation, Tablifier offers a convenient solution to streamline your workflow. Say goodbye to tedious table formatting and let Tablifier handle the heavy lifting for you.

Features

  • TypeScript Support: Tablifier is written in TypeScript, ensuring type safety and compatibility with your project's codebase.
  • Customizable Headers: Easily customize column headers to suit your needs.

Instalation

npm install tablifier
pnpm add tablifier
yarn add tablifier
bun add tablifier

Usage

import { Table } from "tablifier"

const table = new Table("key", "value")
table.addRow("This is the key", "This is the value")

console.log(table.toString())
// output:
// ┌───────────────┬─────────────────┐
// │key            │value            │
// ├───────────────┼─────────────────┤
// │This is the key│This is the value│
// └───────────────┴─────────────────┘

console.log(table.toJSON())
// output:
// [{ key: 'This is the key', value: 'This is the value' }]

API Reference

new Table(...keys)

Initializes a new table instance with the provided header configuration.

keys: (string): The header keys of the table.

Example:

const table = new Table("key", "value")

table.addRow(...values)

By supplying the addRow function with the desired row data, users can effortlessly incorporate new information into their table structure.

values: ((null | undefined | string)[]): The row values to be added to the table.

Example:

table.addRow("This is the key", "This is the value")

table.toString()

Returns a string representation of the table.

Example:

console.log(table.toString())
// output:
// ┌───────────────┬─────────────────┐
// │key            │value            │
// ├───────────────┼─────────────────┤
// │This is the key│This is the value│
// └───────────────┴─────────────────┘

table.toJSON()

Returns a JSON representation of the table.

Example:

console.log(table.toJSON())
// output:
// [{ key: 'This is the key', value: 'This is the value' }]

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request. Here are some ways you can contribute:

  • Bug Reports: If you find any bugs or unexpected behavior, please open an issue describing the problem.
  • Feature Requests: If you have ideas for new features or improvements, feel free to suggest them by opening an issue.
  • Code Contributions: Contributions to the codebase via pull requests are highly appreciated. Before submitting a pull request, please make sure to follow the contribution guidelines below.

Contribution Guidelines

  1. Fork the repository and clone it to your local machine.
  2. Create a new branch for your feature/fix: git checkout -b feature-name.
  3. Make changes and test them thoroughly.
  4. Ensure that your code follows the existing code style and conventions.
  5. Update the README and documentation if necessary.
  6. Commit your changes with descriptive commit messages.
  7. Push your branch to your fork: git push origin feature-name.
  8. Open a pull request to the main branch of the original repository.

Thank you for contributing to Tablifier!

License

This project is licensed under the MIT License - see the LICENSE file for details.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.2.25latest

Version History

VersionDownloads (Last 7 Days)Published
1.2.25
1.2.12
1.2.01
1.1.21
1.0.11
0.0.31
0.0.21

Package Sidebar

Install

npm i tablifier

Weekly Downloads

12

Version

1.2.2

License

MIT

Unpacked Size

13.3 kB

Total Files

8

Last publish

Collaborators

  • sercrac07