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

[DRAFT] feat: console.table implementation #4122

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sumitparakh
Copy link

@sumitparakh sumitparakh commented Jan 12, 2025

console.table features: -

  • Fall back to just logging the argument if it can’t be parsed as tabular.
  • Display array in tabular format
  • Display object in tabular format
  • Restrict the columns shown in the table

This Pull Request fixes/closes #3806

It changes the following:

Copy link

codecov bot commented Jan 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.81%. Comparing base (6ddc2b4) to head (f37f5e3).
Report is 340 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4122      +/-   ##
==========================================
+ Coverage   47.24%   53.81%   +6.57%     
==========================================
  Files         476      485       +9     
  Lines       46892    48386    +1494     
==========================================
+ Hits        22154    26040    +3886     
+ Misses      24738    22346    -2392     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jasonwilliams
Copy link
Member

Yeah this is a good start, you'll then either need a specialized formatter or an argument to the current formatter.
IMO the current formatter is already quite big so it may be worth calling out to a new formatter just for table output.

if you were curious of other implementations, this is node.js' verison:
https://github.com/MrJithil/node/blob/92ad82bdf254392e6dfdcccc7ad29f72958c40c9/lib/internal/cli_table.js which is then called from here; https://github.com/MrJithil/node/blob/main/lib/internal/console/constructor.js#L490-L603

It doesn't look like the algorithm has been formally specified, the last discussion was here:
whatwg/console#21

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

Successfully merging this pull request may close these issues.

Implement console.table() method
2 participants