tablifier
v1.2.2
Published
Streamline table creation for your projects.
Downloads
15
Readme
Tablifier
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
- Fork the repository and clone it to your local machine.
- Create a new branch for your feature/fix:
git checkout -b feature-name
. - Make changes and test them thoroughly.
- Ensure that your code follows the existing code style and conventions.
- Update the README and documentation if necessary.
- Commit your changes with descriptive commit messages.
- Push your branch to your fork:
git push origin feature-name
. - 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.