Skip to content

feat: console.table implementation#5218

Merged
jedel1043 merged 7 commits into
boa-dev:mainfrom
hunterchen7:feat/console-table
Jun 18, 2026
Merged

feat: console.table implementation#5218
jedel1043 merged 7 commits into
boa-dev:mainfrom
hunterchen7:feat/console-table

Conversation

@hunterchen7

Copy link
Copy Markdown
Contributor

This Pull Request closes #3806

summary

  • implements console.table(tabularData, properties) per the WHATWG Console spec.
  • adds a table() method to the Logger trait with a default comfy-table rendering
  • extracts table data into a backend-agnostic TableData struct in a separate table.rs module (as to not bloat mod.rs)
  • supports arrays of objects, plain objects, primitive arrays, mixed arrays, sparse columns, Map, Set, TypedArray, and deeply nested objects (rendered inline)
  • optional properties argument filters which columns are shown; non-array values throw TypeError
  • falls back to console.log for non-tabular input (primitives, empty collections)
  • behaviour attempts to match behaviour of Node.js & Bun (column naming, Map/Set layout, TypeError on invalid arguments, inline display of nested objects, etc)

tests

  • 24 unit tests based on console.table unit tests from Node.js and Bun
  • fallback (4): primitives, no arguments, empty arrays, empty objects/Maps
  • core rendering (3): array of objects, primitive array, object with primitive values
  • Map/Set/TypedArray (4): Map with Key/Values, Set, empty Map fallback, TypedArray
  • complex shapes (3): sparse columns, mixed arrays (objects + primitives), nested objects rendered inline
  • column filtering (5): basic filter, empty filter, nonexistent property, duplicate dedup, filter controls column order
  • nonexistent property (1): filtered columns not in the data still render as empty
  • Map/Set ignore filter (2): properties argument has no effect on Map/Set layout
  • validation (1): non-array second argument throws TypeError
  • security (1): ["__proto__"] filter does not pollute Object.prototype (this test I don't quite understand but it's from Node.js)

some examples

> console.table([{a: 1, b: 2}, {a: 3, b: 4}])
┌─────────┬───┬───┐
 (index)  a  b 
╞═════════╪═══╪═══╡
 0        1  2 
├╌╌╌╌╌╌╌╌╌┼╌╌╌┼╌╌╌┤
 1        3  4 
└─────────┴───┴───┘

> console.table({alice: {age: 30, role: "admin"}, bob: {age: 25, role: "user", active: true}})
┌─────────┬─────┬─────────┬────────┐
 (index)  age  role     active 
╞═════════╪═════╪═════════╪════════╡
 alice    30   "admin"         
├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
 bob      25   "user"   true   
└─────────┴─────┴─────────┴────────┘

> console.table({alice: {age: 30, role: "admin"}, bob: {age: 25, role: "user"}}, ["role"])
┌─────────┬─────────┐
 (index)  role    
╞═════════╪═════════╡
 alice    "admin" 
├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
 bob      "user"  
└─────────┴─────────┘

> console.table(new Map([["x", {a: 1}], ["y", {b: 2}]]))
┌───────────────────┬─────┬──────────┐
 (iteration index)  Key  Values   
╞═══════════════════╪═════╪══════════╡
 0                  "x"  { a: 1 } 
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
 1                  "y"  { b: 2 } 
└───────────────────┴─────┴──────────┘

> console.table(new Set(["apple", "banana", "cherry"]))
┌───────────────────┬──────────┐
 (iteration index)  Values   
╞═══════════════════╪══════════╡
 0                  "apple"  
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
 1                  "banana" 
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
 2                  "cherry" 
└───────────────────┴──────────┘

> console.table([{name: "Alice", scores: {math: 95, eng: 88}}, {name: "Bob", scores: {math: 72, eng: 91}}])
┌─────────┬─────────┬───────────────────────┐
 (index)  name     scores                
╞═════════╪═════════╪═══════════════════════╡
 0        "Alice"  { math: 95, eng: 88 } 
├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
 1        "Bob"    { math: 72, eng: 91 } 
└─────────┴─────────┴───────────────────────┘

> console.table([10, 20, 30])
┌─────────┬────────┐
 (index)  Values 
╞═════════╪════════╡
 0        10     
├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
 1        20     
├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌┤
 2        30     
└─────────┴────────┘

> console.table("hello")   // primitive fallback
hello

@hunterchen7 hunterchen7 requested a review from a team as a code owner March 22, 2026 05:37
@github-actions github-actions Bot added Waiting On Review Waiting on reviews from the maintainers C-Dependencies Pull requests that update a dependency file C-Tests Issues and PRs related to the tests. C-Runtime Issues and PRs related to Boa's runtime features and removed Waiting On Review Waiting on reviews from the maintainers labels Mar 22, 2026
@github-actions github-actions Bot added this to the v1.0.0 milestone Mar 22, 2026
@github-actions github-actions Bot added the Waiting On Review Waiting on reviews from the maintainers label Mar 22, 2026
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 53,125 53,125 0
Passed 51,072 51,072 0
Ignored 1,482 1,482 0
Failed 571 571 0
Panics 0 0 0
Conformance 96.14% 96.14% 0.00%

Tested main commit: de2221a09c132951c2ebad36e62ecd20b9987215
Tested PR commit: def388a804c3a5e1a41af5f95a99a803ca146598
Compare commits: de2221a...def388a

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.44961% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.22%. Comparing base (6ddc2b4) to head (def388a).
⚠️ Report is 980 commits behind head on main.

Files with missing lines Patch % Lines
core/runtime/src/console/table.rs 97.91% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5218       +/-   ##
===========================================
+ Coverage   47.24%   60.22%   +12.98%     
===========================================
  Files         476      567       +91     
  Lines       46892    63161    +16269     
===========================================
+ Hits        22154    38039    +15885     
- Misses      24738    25122      +384     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jedel1043 jedel1043 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you for the contribution!

@jedel1043 jedel1043 added this pull request to the merge queue Jun 18, 2026
Merged via the queue into boa-dev:main with commit 7ce9cae Jun 18, 2026
22 checks passed
@github-actions github-actions Bot removed the Waiting On Review Waiting on reviews from the maintainers label Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Dependencies Pull requests that update a dependency file C-Runtime Issues and PRs related to Boa's runtime features C-Tests Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement console.table() method

2 participants