console-table-printer
console-table-printer copied to clipboard
unicode breaks alignment
trafficstars

const { printTable } = require('./dist');
//Create a table
const testCases = [
{ index: 3, text: 'I would like some gelb bananen bitte', value: 100 },
{ index: 4, text: 'I hope batch update is working', value: 300 },
{ index: 4, text: 'Unicode.... \uD83C\uDD9E', value: 300 },
];
//print
printTable(testCases);
This might be of interest: https://stackoverflow.com/questions/54369513/how-to-count-the-correct-length-of-a-string-with-emojis-in-javascript
Though the fix likely is [...str].length. Example:
let str = `Unicode.... \uD83C\uDD9E`
console.log(str.length) // 14
console.log([...str].length) // 13