console.table text alignment always centered

Version

v18.17.1

Platform

Linux nucke 6.2.0-33-generic #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 7 10:33:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

internal/cli_table.js

What steps will reproduce the bug?

> console.table(["x", "xxxxxxxxxx"])

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior? Why is that the expected behavior?

┌─────────┬──────────────┐
│ (index) │ Values       │
├─────────┼──────────────┤
│    0    │ 'x'          │
│    1    │ 'xxxxxxxxxx' │
└─────────┴──────────────┘

What do you see instead?

┌─────────┬──────────────┐
│ (index) │    Values    │
├─────────┼──────────────┤
│    0    │     'x'      │
│    1    │ 'xxxxxxxxxx' │
└─────────┴──────────────┘

Additional information

The centered content in the table makes output harder to read and counteracts the idea of using a table to display structured data.

A real-world example:

const response = await fetch("https://api.openopus.org/composer/list/search/straus.json");
const { composers } = await response.json();
console.table(composers[0]);
┌───────────────┬─────────────────────────────────────────────────────────────────┐
    (index)                                 Values                              
├───────────────┼─────────────────────────────────────────────────────────────────┤
      id                                     '171'                              
     name                                  'Strauss'                            
 complete_name                         'Richard Strauss'                        
     birth                               '1864-01-01'                           
     death                               '1949-01-01'                           
     epoch                              'Late Romantic'                         
   portrait     'https://assets.openopus.org/portraits/29972276-1568084951.jpg' │
└───────────────┴─────────────────────────────────────────────────────────────────┘

It is also not clear why the Node.js implementation differs from those in current browsers:

Edge:
image

Firefox:
image