hustcer/star

Use `text-table` to align console output

Closed this issue · 4 comments

Use text-table to align console output

Delay

text-table does not work not well with Unicode characters, see issue

You need to pass a string length function that would take wide characters into account.

var table = require('text-table'),
    wcwidth = require('wcwidth');
var t = table([
    [ '**好声音', '1024000' ],
    [ '舞蹈', '33450' ],
    [ 'foo', '1006' ],
    [ '中文对齐有点儿问题哦', '45.08' ]
], {
  align: [ 'l', 'r' ],
  stringLength: wcwidth
});

console.log(t);