32

Is it possible without installing new package?

Here i am using cli-table package.. enter image description here

Any easy way to do it ?

Hemanthvrm
  • 2,319
  • 1
  • 17
  • 26
  • 1
    Don't think there's any *easy* way to do it. Why not look into the `cli-table` source code see what it does? – hackape Apr 09 '19 at 04:25

2 Answers2

77

You can use console.table() API without installing any node module. NodeJS Added in: v10.0.0, Browser compatibility

const structDatas = [
    { handler: 'http', endpoint: 'http://localhost:3000/path', method: 'ALL' },
    { handler: 'event', endpoint: 'http://localhost:3000/event', method: 'POST' },
    { handler: 'GCS', endpoint: 'http://localhost:3000/GCS', method: 'POST' }
];
console.table(structDatas);

The stdout in terminal like this:

enter image description here

Lin Du
  • 88,126
  • 95
  • 281
  • 483
7
var values = [];
Array.forEach(function(b, i) {
    values.push(
    {
        'Symbol': b.a,
        'BID': b.b,
        'CONVERT1': b.c,
        'Buy': b.d,
        'Sell': b.e,
        'Convert2': b.f
    });
});
console.table(values);

Result Console

Result Console

Alfonso
  • 644
  • 7
  • 17
Jack Huỳnh
  • 79
  • 2
  • 3