gajus / table

Formats data into a string table.
Other
904 stars 76 forks source link

Minor defect in alignCenter logic #115

Closed michaelgwelch closed 4 years ago

michaelgwelch commented 4 years ago

On line 38 you should be checking (I believe) that width is even, not half-width.

https://github.com/gajus/table/blob/37fa97ce4b8cbaa4265858935d1489d882f17cd8/src/alignString.js#L33-L45

Here's a little program to illustrate the issue.

#!/usr/bin/env node
const { table } = require('table');

const data = [
    ["ten characters"],
    ["ten characte"]
]

const config = {
    columns: {
        0: {
            alignment: "center"
        }
    }
}

const output = table(data, config);
console.log(output);

And here's the output

> ./index.js 
╔════════════════╗
║ ten characters ║
╟────────────────╢
║  ten characte   ║
╚════════════════╝
gajus commented 4 years ago

:tada: This issue has been resolved in version 6.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: