Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added a helper function to print multiple tables at once. #392

Merged
merged 0 commits into from
Aug 1, 2022

Conversation

ArjixWasTaken
Copy link

👀What is this pr about?

This PR aims to add a function that will print multiple tables at once.
If the size of the terminal cannot fit them side by side, it will print as many as it can at once
And print the others below, side by side.

🚀 Changes

Added

  • printTables

Fixed

#375

Before After
🧟 😎

@ArjixWasTaken
Copy link
Author

The function can be imported like this:

import { printTables } from "console-table-printer/utils/table-helpers"

And you can pass any number of tables into it in order to print them.

@ArjixWasTaken
Copy link
Author

ArjixWasTaken commented Aug 5, 2021

PS:

I didn't test this package wide. (In other words I didn't reinstall the package in order to test.)
I only tested the function directly.
So please check for me because I'm super lazy.

@ArjixWasTaken
Copy link
Author

For some reason this took way more effort than what it's worth.

@ArjixWasTaken
Copy link
Author

Wow, now that's a long time of inactivity there.

@ayonious
Copy link
Owner

as mentioned in #375 this does not seem like a feature that many would use.

But also looking at code its little difficult to understand. Im okay to put the simpler version without considering the width. That way at least the most common cases will be handled.

@ArjixWasTaken
Copy link
Author

If the code is difficult to understand then I can explain it (or even refactor when I'm back from my trip)

It basically tries to merge as many tables as possible, if the character limit is reached it then prints them below.

Think of it like a buffer, you save data up to the buffer size and then flush the buffer.

That's what I do, I make a "buffer" that gets flushed when the end is reached or the maximum character limit gets hit.

@ayonious
Copy link
Owner

ayonious commented Apr 1, 2022

@ArjixWasTaken thanks for putting time into this.

But to make it maintainable, more things needs to be changed:

  • There could be more variable naming, new functions creating, unit tests creating done on this one.
  • Readme updates on how to use this
  • Also maybe its better to expose the function to be directly accessible instead of this utils file.

@ayonious ayonious merged commit c9e8994 into ayonious:master Aug 1, 2022
@ArjixWasTaken
Copy link
Author

ArjixWasTaken commented Aug 1, 2022

oof, pull bot made my PR empty...
worst bot in existence

@ArjixWasTaken
Copy link
Author

thankfully a version of the code is available here

@ayonious
Copy link
Owner

🎉 This PR is included in version 2.11.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants